Debug a program with the following steps:
- Review the bug report#
- Characterise (determine the context where the symptoms showed) and reproduce the bug with the given input
- Create the same bug with new input
- Understand#, locate# and classify# the bug iteratively
- Attempt to repair the bug
- Deliver the fixed version of software
Note: Write a new test to reproducible bug.
Note: An unexpected behaviour might not be a defect. It is possible when a case, not thought before the formulation of the requirements, is not being handled by the program.
Note: A repaired bug must pass all the tests including the new and old one.
Note: Good version control could help.
Note: Always double-check the test assets! For the new and old tests.
Note: Always assume that the bug is coming from the application itself. If after elimination that the bug is certainly not coming from the application itself, then we can say that could result from external factors such as
, compiler or third-party component like library.Difficulties
There might be some difficulties during the debugging which make oversight possible or bug hard to solve.
Symptoms and defects can be correlated which resulted the symptoms could change upon repaired or as the repair progressed. This could mean that the actual fault might be several steps away from what have observed. Fixing one defect could result in introducing more defects which is not ideal. [Hunt et al.](lit/@Hunt1999)❌ suggest trying to find the root of cause of a bug.
If the symptom(s) is difficult to reproduce, it suggests a possible non-deterministic defect, a defect that given the same input could yield different results, that need more attention during the debugging process.
Documentation
Document down a defect by following the guide below:
- How does the defect been noticed?
- What is the context where the defect happened?
- The step to reproduce such defect.
- The techniques and tools involved to fix such defect.
- What is the category of the defect?
- What is the root cause of the defect?
- What latent defects have been avoided after this fix?
- Is there possible latent defects left unaddressed?
- What is the mistake that cause such defect and how to avoid it?
Reference
Back to Basic: Debugging Techniques, YouTube, Bob Steagall