Q: When was the last time you discovered a software bug?
A: I discovered one today.
Q: What did you do with the bug?
A: I fixed it.
A: Life goes on.
Above are not the correct questions to ask our self whenever we found bug in our code. Almost exactly 20 years ago, a man has given us his wisdom in form of three questions to ask when we found a software bug.
The questions are: (I am rephrasing the explanation to make it memorable to my own memory ^_^)
- Is this mistake somewhere else also? We need to think whether similar programming technique that introduced the bug also used in other section of the code. If it is, we need to look at that section and investigate whether the same bug will appear there.
- What next bug is hidden behind this one? Are we going to probe left and right, sort of trial and error to fix the bug? Or, are we going to understand why the bug appeared in the first place? We must also ask our self what will happen if we fix this bug. Are we going to introduce a new bug? Another important issue is how are going to proof that our bug-fix is going to work? What kind of test cases that we need to introduce? What conditions that will be covered by the test case?
- What should I do to prevent bugs like this? The last question is sort of reflection on what we have learned by answering the first and second question. We must study and remember our bug discovery and rectify experience, so that we will not fall into the same pitfall in the future.