2 ms·
I don't recommend reading code for an exercise (at least not by itself). I do recommend modifying code as an exercise though. There are lots of pieces of code
by j_baker 16y ago
I don't recommend reading code for an exercise (at least not by itself). I do recommend modifying code as an exercise though. There are lots of pieces of code that are deceptively complex: they look simple, but come to a grinding halt when you make the slightest change. Thus, it's important to know that there's a difference between what code is doing and what it looks like it's doing.
This teaches a few things:
1. How to read code
2. How to write code
3. How not to write code. When you encounter the grinding halt effect I mentioned above, there's a good chance that's how not to write code (but maybe not, some code is naturally tricky).
- sant0sk1 16y agoGood point. In the article I also point out that you should not be reading code passively. You should be running the tests, executing the code, breaking stuff, and trying to fix it.
- j_baker 16y agoI noticed that. Perhaps my point is more of a semantic one. It still seems to me that the article seems to focus more on the reading than the modifying though.
- lanstein 16y agoThat reminds me of a line of code I wrote the other day: $result->RetrieveResult->DynamicEntity = clone $result->RetrieveResult->DynamicEntity; it's to get around a PHP bug where the SoapClient returns a half-baked object. At least I preceded it with a comment.
- dhimes 16y agoThis is also a great exercise to improve your writing of prose, if anybody is interested. Take a well-written couple of paragraphs (Hemingway, etc.), and try to write it better. It's a short exercise that teaches you the importance of the subtleties of style.