I’ve decided to start a tradition (April Fools’ Day is as good a day as any to start this, right?). I often come across axioms in software development…short, pithy statements that attempt to express some greater truth. Some are terrific. Some a little less so. Every Wednesday, I’ll explore one.
Today’s axiom is: Read more code. Ideally, read more code than you write.
I extracted this axiom from James Edward Gray II’s great presentation at MountainWest RubyConf 2009. It really makes perfect sense…if you want to be a great writer, you read. Lots. None of us would respect a writer who didn’t read much. Yet it’s all too common (I’m guilty too, I admit) to not really seek out code to read. With basically all of the Ruby universe being open-source, there is a treasure-trove of interesting code to look at.
One tip James gave at the conference was to not start out by finding the hairiest, most complex code to look at. find a module that is fairly simple and straightforward (actually, Watir is great for this), and look at the source to see how it’s put together.
Some advantages James mentions of reading code:
- It can show you common idioms
- It’s good to practice breaking down possibly challenging code, because you will always have to work with other’s code
- Understanding how something works give you insight into any limitations it has
- Seeing bad code helps you write better code
- Knowledge workers always need more ideas
No comments:
Post a Comment