The Art of Debugging

It was a sunny day, I stepped in my car and started out for work. Within the first hundred feet of the car moving, I heard a muffled but regular “thup a thup a thup”. I stopped the music and it was still there, I pulled over and got out of the car. Did a quick visual, checked if my bumper was hitting the tires, saw nothing amiss and started again. The sound persisted “aargh!”. I pulled over again. I saw a elderly gentleman approaching, great luck. I lowered my windows and asked if he could see any obvious flaws as I would attempt to move the car slowly. Hoping for a affirmative, I was aghast when he gestured to me that he was extremely hard of hearing.I got down again and started looking at the tires again. Then there it was stuck on my front tire, some kind of a poly wrappng material. Each time the tire  rotated the portion that wasn’t stuck was hitting the area above the tire. I took it out and problem solved. I had just completed debugging my car. 

In fact debugging is very much a part of programming as it is in daily life. best advice I got out of college was “learn to debug”(a). It would be analogous to doctors figuring out what is wrong with a patient or a mechanic finding trouble with a car. The goals similar, but the objects and tools employed different. 

Java being my primary language I started out with these excellent eclipse debugger videos.

More recently I’ve been using winpdb( for my Python exploits.  These days I debug, a lot! I would think the best programmers will be extremely good at debugging as well.

Some of the techniques I’ve come to employ are:

1. Reduce the problem space.

2. Use print statements(for localized problems).

3. Use Debuggers  (which was my original intent in asking the elderly gentleman)

4. Logs: Logs give a long term state of the system when turned on. Of course its very easy to have them running into millions of lines which leads me to point 1. again.

The other use of debuggers I make is to understand the behaviour of unfamiliar programs. When a reading is not sufficient, It is quite handy to spin up the debugger and step through the program seeing the state of the data that it manipulates. I call it an art since no single technique is guaranteed to give a solution. How to debug problems consistently with a low time investment is certainly an art. I would love to know the techniques that you employ to debug programs and life in general.








a.What is Debugging? At its essence given a system with x as a known and expected behaviour and y as undesirable behaviour, the task of reconciling the difference and finding the root cause is debugging.

4 thoughts on “The Art of Debugging

  1. I think the best way to debug is first to think where the problem could be, and then to exam the code by looking at it. It is far more efficient than step through in a debugging tool. However, this requires good understanding of the product.

  2. art of debugging. I love the name. Debugging is certainly difficult problem that we, as programmers, encounter more than others. But we are lucky in some sense. Our system do not suffer from time. Like your car, parts will get older with time and system behavior change. Software in other hand they are time independent (almost hardware failure). So to solve your problem. Program without a bug (this is debugging avoidance solution). Is it impossible solution? Well nothing is impossible. We just did not try enough!Anyway good post. I like reading your post time to time.PS: At its essence given a system with expected behaviour x, but actual behaviour y, << this is not 100% correct. If it is x expected than y is also a possible behaviour. It should be x is known behaviour and y is undesirable behaviour for this system. If y can be avoided than it is a bug if not that is also a possible behaviour.

  3. Peter, updated the definition 🙂 . thanks for reading. I disagree on time independence for software though. It may be true for smaller independent programs that we use for research but as new features/ users at scale come in commercial products, code will be updated.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s