July 10, 2014

Chappell's Second Law of Programming

(One from the archives. I wrote this ten years ago. I think it still stands.)

With all of the benefits of modern computer science research, I find that many programmers still omit one basic thing from their programs. No, I'm not talking about patterns, or POJO's or any of the other trendy buzzwords that a modern programmer is expected to be knowledgeable of, rather I'm talking about something more basic than that.

I'm talking here about the ability to:

Write code that you can read at 2 a.m.

As any programmer that has taken a support call in the middle of the night will tell you, supporting other people's code is the worst. At least with your own programs you know why you wrote them and what they're supposed to be doing, but with someone else's, you usually don't have that luxury.

This will usually result in frantically looking at any available code for the program to see if it offers any clues about it's purpose for existence. Naturally, this is where you discover that the author had the bizarre habit of using single letter variable names for everything and you can't understand a thing. And not a comment in sight, of course.

The answer, of course, is to assume that someone might need to understand your code in a hurry and that you should write it clearly and concisely, so that it can be read even at 2 a.m. by someone in a frantic hurry, that is still trying to rub all the sleep out of their eyes and who is unlikely to have a copy of the specification around to read.

Tags: Software Geeky One From The Archives