Reading an interview with Kirk Pepperdine, I came accros the following statement:
Dumb code tends to be more readable and hence more understandable.
In it’s daring generality, the statement is absolute non-sense.
I have seen some really dumb code. Dumb code of hopelessly deep nesting so as to blindly adhere to the single exit point rule. Dumb code that repeated the same kind of statements in sequence, page by page by page, where a loop would have done it. It was not understandable at all, let alone easily changeable.
Among the dumbest code I see is “copy-and-paste code”. In fact, clipboard reuse is probably the most frequently used reuse “technique”1. Why? Because it’s so dumb easy. There’s practically no entry barrier to CTRL+C,CTRL+V, compared to the relatively high entry barrier to (possibly continuously) making thorough software design considerations.
This is not to confuse with simple code. Truly simple code is worth every effort going for.2 But there’s a clear difference between the simplicity of our actions, and the simplicity of the outcome of our actions. Doing the simplest thing that could possibly work is not a simple process3, as simplicity is rarely achieved by doing the obvious.
Truth is: Dumb code is not simple. Dumb code is dumb!
Martin Fowler makes the accurate observation, that “some people’s intention revealing code is another’s cleverness”. Indeed, novice, unskilled programmers may be overburdened by designs that are routinely applied by their more experienced workmates. In a provocatively generalized redraft:
Clever code is written by clever programmers. Dumb code is …
[I leave it up to the reader to finish the sentence.]
In the end, I think a preference for “dumb code” is as far-off from universal wisdom as it can be. Instead of aiming for low standards, organizations should ask themselves if they wouldn’t be better off having more clever programmers around.
- and the most frequent source of code dumbness [↩]
- As Antoine de Saint-Exupery said: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. [↩]
- as indicated by the final sentence in the outline of the XP practice: “Beware though, keeping a design simple is hard work” [↩]