Jeff Atwood recently wrote about what he calls The First Rule of Programming: it’s always your fault. That is, we should resist the temptation to blame the OS, the tools, the framework, and other technologies when the problem might still lie with our own code. To explain some of the merit in this idea, he quotes an anecdote from The Pragmatic Programmer about a senior programmer who was solidly convinced that an OS system call was buggy until he was forced to read over the documentation carefully. Once he fully understood how the system call was actually supposed to work, he fixed the problem in his own code within a few minutes. This story reminds me of many debugging sessions I’ve had while working at Tenthline.

One very common scenario we run into, especially when learning new technologies, is going over misbehaving code that we’ve written with a fine-toothed comb and not being able to identify a single problem with it. At that point, it’s all too easy to jump to the conclusion that there’s something wrong with the technologies that we’re using. Then, without fail, Michael always says “wait a sec, let’s check our assumptions.” At that point, we start analyzing the code very carefully to see if we’ve made any implicit assumptions about the way that the code we’re calling on works that actually aren’t true. After all, sometimes abstractions leak or we’re in such a rush to apply the technologies to what we’re working on that we skip over some of the important details when reading the documentation. If our assumptions turn out to be incorrect, it is usually much easier to fix the problem in our code from there. And even if we can’t fix the code, we still end up with a fuller understanding of the problem.

Even if it isn’t always our fault, I think that it’s definitely a good habit to force ourselves to assume that it is. At the very least, it forces us to do extra work to fully eliminate the possibility that the fault lies with us instead of just jumping to conclusions.

Tags: