“Do not read just code, learn algorithms”, OK, But . . .

I just read yesterday’s Take Outs (by Ken Tegels) which pointed me towards Frans Bouma’s blog which boldly states “Do not read just code, learn algorithms”. I completely agree that good algorithm design is a valuable skill to have, and its not a that applies only to software engineers.

Surgeons invent new life saving techniques every day and document them as a precise algorithm for others to follow. But would you want a surgeon that had never touched a scalpel and doesn’t appreciate its form an handling touch your body? What about the body of one of your children?

Frans, I think you might be missing the point on why people look at code. They aren’t necessarily looking to distill a design from it (although doing a code walk can sometimes help link islands of information together), instead they are looking for form. One classic benefit that I got from reading copious amounts of other peoples code was declaring variables just in time (as opposed to just instansiating just in time).

The reason is that when it comes to refactor the code (you know, behaviour preserving modifications), tool support works best with just intime declaration (think of the Extract Method scenario).

Learning is an iterative process, the act of implementing your design in code (and seeing others implment your design in code) makes you a better designer the next time around – this is where ivory tower architects get into trouble.

In short, good designers don’t buy a one way ticket when going from design to code. Sorry for the mixed metaphors . . . .


2 thoughts on ““Do not read just code, learn algorithms”, OK, But . . .

  1. Frans Bouma

    If a developer doesn’t understand how to translate an algorithm to code, then the developer is useless, agreed. Therefore I didn’t say: don’t read code. I said: Don’t read JUST code. 🙂 Reading just code is useless, you won’t learn a thing. Read the algorithms and learn them. Then translate them into code. That’s learning too, the best way to learn development of software.

    The discussion started with the question: which sourcecode to read to learn something? Or to use your methaphore: which surgeon-TV show to watch to learn how to operate on humans? 🙂

  2. Mitch Denny

    Hi Frans,

    I did pick up that subtle word in the title 🙂 My argument is that equal importance needs to be placed on codefu and algorithm design (incorporating problem solving skills).

    Back to my metaphor: I wouldn’t equate watching surgeon-TV being the same as looking at the code. Maybe (and this is where metaphors come unstuck) its more like a surgeon learning how to use a scalpel whilst working on a rat in the lab.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s