5 Steps to Debugging Code

Since I don't have any code to post, I decided to share more of my experiences regarding software development in general. This is base on real world experience. Sometimes, I tend to go on and proceed with solving the problem without doing sufficient analysis. I think my experience doing maintenance work has helped me mature and be more analytic towards solving problems.

 

1. Find out what's the problem - Find out what's the problem first is the fundamental question asked in Math in grade 1. It's like What is asked?

 

2. Find out where the problem lies - Secondly, when you've identified what the problem is try to find out where the problem is. There is a big chance that there is no problem at all and the problem might be the user. I'm just stating that as a possibility but of course there's always and higher chances that there is a problem with the software involved.

 

3. Find out What's causing the problem - In this step, you identify if the problem is being caused by a dead server, typo, logic error, etc.If it's a NullPointerException, where is the offending code and why is it causing a that? It's very tempting to conclude that such problem is caused  by a call to a null reference but it's more often more than that.

 

4. Research how to fix the problem - Once you know what's causing the problem, it's time to propose solutions. There can be many ways to approach a problem so it's good to identify your options. Then from that list of options, identify the best solution. It's always a good idea to ask other people for a second opinion.

 

5. Code the Solution - Finally,  you have decided on a solution it's time to code. However, before writing your first code it's always a good idea to write unit tests against them. Now, I feel a little guilty having discussed this because I tend to go lazy sometimes and just code straight away. It really totally depends on how much time you have but for maintenance work, I would suggest to write unit tests first. You will then know that your solution works such as when you put your changes the unit tests passes and when you take out your changes the unit test fails.

Published 08-08-2010 3:20 AM by lamia