Thursday, April 23, 2009

Structured debugging process

Debugging should never be done chaotically. Below you can find instructions how to debug in a structured way.

  1. Duplicate the Bug
    The most important, no repro no fix
  2. Describe the Bug
    Keep it in database – easier to track changes
  3. Always assume that the Bug is yours
    If bug is in your code you can fix it, if not = trouble; eliminate any possibility before looking elsewhere
  4. Divide and conquer
    Hypothesis and elimination, look into code, like a binary search.
  5. Think creatively
    Version mismatches, operating system differences, problems with program binaries or installations, external factors
  6. Leverage Tools
    Helps to investigate e.g. Error detection tools (invalid memory accesses, parameters to system APIs and COM interfaces)
  7. Start Heavy Debugging
    Much time on exploring program's operations
  8. Verify that the Bug is fixed
    Easy when isolated module, harder in critical code – verify for all data conditions, good and bad & regression. Changes to critical code => inform the team!
  9. Learn and Share
    Summarize what you have learned and share with colleagues – helps eliminate the bug faster.

Of course there is no need to follow all the steps. If the bug is found and fixed just go directly to the step no.8

The steps are taken from an excellent book "Debugging Applications for .Net and Microsoft Windows" by John Robbins.

No comments: