Monday, October 04, 2004

Cleverness considered harmful

Chris Sells posted this quote today:

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
--Brian Kernighan


I tend to carry around a toolbox of not very clever, tried and true, techniques that I trot out for nearly every problem. This is probably a little reductionist, but it keeps me from getting into trouble. I used to get in trouble a lot.

When I find things are getting complicated, I know this is a sign that I don't really understand the problem. Sometimes, though, you need to write clever code to get to a place where you know enough to simplify it.

Still, this is a great acid test. If you find that you are stretching your mental limits just to write the code, then what chance do you have to maintain it?