Code Debugging - Is it easy?

by Yugolancer

Posted on Thursday, February 22, 2018

As mentioned many times by now, Debugging is a discipline that requires patience, and a fervent attention to detail.

When it comes to solving difficult problems, issues or bugs, you need to locate, and resolve the problem's root cause.

Usually it happens that, after going through one idea after another and hitting debug button for an hour (usually more like 2 or 3 hours), you are not closer to solving the problem than you were when you started.

Now, all you've done is wasted a few hours of time, and worked yourself into a desperate and frustrated state that is not conducive to thinking rationally, and applying logic.

Simply because you don't actually have any clue what's causing the problem you are just shooting blindly.

The problem is often, if not always, more complicated than we would like.

As developers, we would much rather add new features, or write the next great algorithm, than try to figure out why something we wrote a month ago is suddenly no longer working.

"Stop thinking, and look!" - is one of the maxims from David Agan who points out that the engineers like to think and not to look.

Why? Well because the thinking is fun. In fact, for a lot of us it's probably why we became software engineers in the first place.

So why do we insist on being able to locate a bug by thinking about it? Probably because it's a lot easier than looking for it.

Of course, looking is tedious. Sometimes you don't even know where to start looking.

However, in order to be certain that you're fixing the right problems, and that you can prove that you've fixed it, make sure that every time you debug a problem you:

  1. Observe the issue in action
  2. Apply your fix
  3. Observe that the issue is resolved

If you don’t do these steps, in that order you can’t know if you actually solved the issue at hand, another different issue, or just wrote a bunch of code that does nothing at all.

So avoid frustration, don't waste time solving the wrong things, and stop thinking, and look already!

Copyright © ASPNETer 2006 - 2016