About Code Dumbness And Programmer Cleverness
Reading an interview with Kirk Pepperdine, I came accros the following statement:
Dumb code tends to be more readable and hence more understandable.
It is a position I discover quite frequently, in particular with people from management. It’s about time to present a different view:
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” [↩]
Kirk, thanks for coming back to it.
I’m aware of what the original intention behind the notion “dumb code” was, and I did not assume for a minute you meant “stupid code”. But still, generally speaking, such statements are more of a value judgment then of a wisdom – and a value judgment based on a diffuse concept at that. That’s why I have my issues with it. I’ll post about it in more detail soon.
That isn’t what I mean by the term dumb code. What you’ve described is stupid code. What I was getting to was an avoidance to use “clever” code just because. I use “clever” code when I need to. H*ll, I’ve even dropped into assembler when I’ve needed to. It just not my first choice to do so. And when it is my first choice, I will ask why.
Regards,
Kirk