Discover more from Dancing Monkeys
Debugging Changed My Life
We’re all familiar with bugs in software. As a programmer, the most important discipline I ever learned was how to debug code.
A bug is when software doesn’t behave the way you expect it to. This doesn’t have to be something as serious as a crash, it could just be a button appearing slightly off the edge of the screen, or a small delay between user input and program response that makes it seem as if there is a problem with the software.
When I started programming back in 1982, I learned assembler programming very quickly. Assembler was the only way you could get adequate performance from the limited hardware available at the time. Assembly programming is very labourious, and if you’re not fastidious about all of your assumptions, and if the expected behaviour is not clear in your head, then the smallest mistake can result in a fatal crash on one of these early machines, including lock ups so bad, that the machine has to be reset, and then you have to load everything up from cassette tape. So in those days you had to be very defensive about your code.
To program defensively means to expect mistakes to happen and to make provisions for such mistakes, before these mistakes can wreak havoc with the remaining assumptions in your code.
So how did debugging change my life? It taught me how to solve problems, to stay calm in the face of pressure, to accept personal responsibility, and to be utterly relentless and focused. These are skills that are valuable in solving all kinds of problems, and they are also immensely valuable in life in general.
Solving problems requires that you gather the facts, ask questions, create a hypothesis, test the hypothesis and repeat until the problem is solved. If you think about it, this is the core of the scientific method.
When facing deadlines, or the requirements of a stressed publisher, or a nervous client, you have to stay calm. If you are unable to stay calm, you will flail around wildly trying scattergun approaches which are likely to make the code worse, or you will end up patching in a terrible hack, which will cause problems elsewhere, and when it’s too late to fix them. It is therefore utterly essential to stay calm, gather your focus, and continue with the methods required to isolate and fix the bug.
My favourite aspect of debugging, is accepting complete personal responsibility. There is no injustice in code. This is one of the reasons that I love programming so much. One of the first maxims I have learned before I became a professional video games programmer was GIGO, or “garbage in, garbage out”. The only person putting garbage in was me, therefore I was responsible for the garbage that was coming out. When you accept full personal responsibility for the results coming from your software, you are completely empowered to solve the problem. You don’t have to rely on anybody else, you know that you have it in you to fix the problem, because you created the problem in the first place. If you can tidy your room you can debug code.
Finally, you have to remain focused, and relentless. You have to develop the belief, backed up with evidence from previous successful debugging runs, that you can do this. It’s like when you lose something, if you’re systematic about retracing your steps, and you can accept that you are responsible for misplacing the house keys, then you feel totally empowered. The scope is clear, you know that the keys have to be in the house somewhere, you have to resign yourself to turning the entire house upside down, room by room, inch by inch, but you will find those keys. Having this mindset allows you to settle in for the long haul and to persist with focus through the hardest problems that you could possibly imagine.
I’m not going to bore you with analogies here, you can see that these skills will serve you well anywhere, and in any situation. These skills will help you to control ego, they will help you to control arrogance, and they will bring down your hubris until you are a pure problem-solving machine, when needed.
Debugging will teach you lateral thinking. Debugging will help you to refine your nose for seeking out problems. Debugging will help you to remain calm in the face of overwhelming pressure. And every time you fix a bug, you add a brick to the house of your self-reliance and self-worth.