How to Handle Debugging Problems
Debugging is hard, and one of the main reasons why programmers spend so much time fixing previous issues. It is no surprise that spending time on code debugging will inevitably reduce the available opportunities for more productive endeavors.
That is why it is so important to learn how to handle bugs efficiently. First, let’s see the main culprits for the introduction of bugs in software. Here is my list of the top items that contribute to their occurrence:
Unclear code: if your code is hard to read, it will also be hard to maintain. Problems usually happen in areas that are poorly understood. You should strive to make your code as clear as possible, and reduce the possibility of errors caused by hard-to-read software.
Badly engineered code: another big culprit is code that hasn’t been designed correctly. If your design doesn’t work from the beginning, there is not way to avoid bugs.
Bad requirements: sometimes the problem is not on the programmer, but on requirements that change, provoking problems down the road when the system is integrated and used.
To handle these problems, you need to do some reverse engineering, and think about the problems I mentioned above.
Is the code unclear? If so, how would you write it in a clear way? Even if you cannot rewrite the system to improve it, you will at least have a mental model of how it should work. And in the process of fixing the bug, you can most certainly clarify the way the code is used, so that future problems will occur less frequently.
Is the system badly engineered? When this happens, you can propose ways to fix the system. Redesigning how the whole system works can avoid big trouble in the future. So, the occurrence of a bug may very well be the sign that the system needs additional work on the design side.
Bad requirements are the problem? In this case, you should clarify the requirements, and probably write them down so that in the future you can refer to them. Business requirements are a common source of confusion, because different users have a different view of how the system should work. As a developer, your work should be to come up with a clear solution that can satisfy the basic needs of all users, if possible.
About the Author
Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.