Tuesday, November 27, 2012

The Essential Process of Debugging

According to Chapter eight (“Defensive Programming”) of Code Complete, it talks how we can protect our program and how we can avoid error. It talks about the ways to make defensive program, such as Assertions, Exception, and Debugging. I think that the most important thing of Defensive programming is debugging because debugging is essential part of programming. I think that programming is rare to complete and run perfectly at once. It means that writing code perfectly is almost impossible. It usually has some errors because of lack of code. Of course, debugging is not only needed to complete writing code good to learn how we got wrong and to fix it. The reason why it is also good to learn is based on process of debugging.

What is process of it?

  1. Check the bug exists or not.
  2. Check where bug is in program.
  3. Check why error occurred.
  4. Make sure of way to fix it/ concern about correct way to run program.
  5. Fix and test it.

1, Check the bug exists or not:
 The purpose of this step to identify or find sigh of bug and knowing a situation that error occurred and knowing the way to avoid error.

2, Check where is bug in program:
In this step, we need to find and identify which program cause error.

3, Check why error occurred:
After we find a bug, we will need to know how error occurred. For example, the situation is program stops because of failure of data field. In this case, finding error of data field is purpose of this step.

4, Make sure of way to fix it/ concern about correct way to run program:
After we know the reason that program stops, we need to think about how to fix it. In this step, we need to know detailed information of what program is made for because some solution could change its purpose even if error is fixed. 

5, Fix and test it:
After we find correct way to fix the bug, we need to test it and make sure that the way we try to fix deal with the bug or not and it cause undesirable side effect or not.

Thus, each step is important to complete code and fix program. In addition, those steps can tell us what, where, and how we got wrong. If we learn how we got wrong and fix it. We can avoid similar error next time.


  1. I strongly agree with your idea that debugging is one of the most important steps when writing codes and developing programs. As you have mentioned, it is nearly impossible to write perfect compilable lines of code without any process of debugging and therefore it is crucial for any programmers to be aware of efficient ways of debugging .. Great post!

  2. Nicely formatted post Yoshi, however you should be aware of Google's motto "Testing Rocks! Debugging Sucks!". While debugging is very important, there is a strong movement in the software to say that debugging is no substitute for having a good testing infrastructure in place. This is something that Dave and Armando touch on a number of times in the EdX lectures - I do hope you take the time to watch them all. Ideally as soon as you find a bug you should wrap it in a test, an automated test that will mean that you can automatically check for the presence of that bug in future. Then debugging is one of the tools that you can deploy to help fix the bug and make the test pass ...

  3. That is good comment, but I feel that Google has the resources to back up its motto "Testing Rocks! Debugging Sucks!". I guess another way to put it is, debugging will fix the problem, but testing prevents the chances of another bug popping up in its place.