Source code: The untold story.
A lot of people hate reading other peoples code. Especially code bases that are very old. And while I must admit that trying to modify someone elses code is a real pain, sometimes sitting back and reading old code is rather enlightening. You may be sitting there looking at a piece of code trying to figure out what crack the developer was on while they were writing it[1], but you have to remember every line of code is there for a reason. Every single one. The code that half implements some feature is there for a reason. The author obviously decided that it was important to write at some point and then changed their mind. The code which is no longer relevant speaks of a time when that code was relevant. Code that works around some long forgotten bug in some library or kernel, or some limitation of a long dead compiler speaks volumes about what problems people in the past had to face. Code that tries to shave an extra 1kbyte here, and an extra 1kbyte there talks about what hardware that the programmers had to deal with. Code that has massive optimisations performed by hand by the programmer speaks to a time when CPU resources were limited, and the compilers weren’t smart enough to discover the optimisation for themselves. Code that never had any effect is a brief insight into a programmers idea of what the program is doing (even though it’s wrong). Bugs speak about the competancy of the developers and usage patterns of the users. Variable names also show what the developer originally thought was going on when she choose the variable name, (but not necessarily what they realise it does today). Comments provide short sentances in the story of the life of the program. Even which license chosen by the program explains a lot about what the original developer(s) wanted from the program, and what they were hoping to happen to it.
So next time you’re looking at code, cursing and swearing, stop to think about the story of the program. At least it’s an interesting diversion.
[1]: Surprisingly enough, I have found code where the authors do claim to be smoking crack while writing it….
March 19th, 2005 at 3:28 am
:-)