Great example. About a clever technique. And implementing it in the author's own code.
Check out Dr. Spinellis' Code Reading:
"Code reading requires its own set of skills, and the ability to determine which technique to use when is crucial. In this indispensable book, Diomidis Spinellis uses more than 600 real-world examples to show you how to identify good (and bad) code: how to read it, what to look for, and how to use this knowledge to improve your own code.
Fact: If you make a habit of reading good code, you will write better code yourself."
There are also tons of good code around. Most large, successful open source projects have source code full of gems from which we can all learn. Even better, by participating to a large open source project we can also learn a lot from the processes used in it.
What I think is important to keep in mind is that reading good open-source code is what helps. I'd make sure a piece of code was written by a fair number of smart people and used by others before I started copying their idioms and emulating their style.
Two kinds of learning, right? Learning by example (e.g. reading books, reading others' code) and learning by doing (e.g. experience building things, writing your own code).
I agree 100%. I think it usually comes down to confidence: if you're not confident in your ability, it's all too tempting to try to learn "just a little bit more" and never take the plunge enough to practice. On the other end of the spectrum are the audacious "rock star developer" wannabes.
Skillful programming requires a weird mix of both attitudes.
Check out Dr. Spinellis' Code Reading:
"Code reading requires its own set of skills, and the ability to determine which technique to use when is crucial. In this indispensable book, Diomidis Spinellis uses more than 600 real-world examples to show you how to identify good (and bad) code: how to read it, what to look for, and how to use this knowledge to improve your own code.
Fact: If you make a habit of reading good code, you will write better code yourself."
http://www.spinellis.gr/codereading/