Home

Tips when debugging

Do you know that uneasy feeling when you're debugging and just trying stuff out without a plan aka programming by accident?

use that uneasy feeling as a trigger to stop and make a plan. Debugging a bug is often complicated and sometimes a large effort. Don't always aim to fix it in one go. Make  intermediate goals that will help you solve the bug. Some ideas to think about:

reduce your search area:

  1. remove code without making the bug disappear
  2. use git bisect (google for more info)
  3. reduce the size of the data you're working with (less data to sift through when console logging)

increase visibility:

  1. render data to your UI. JSON.stringify is your friend. Don't restain yourself to the console.log
  2. Use a debugger and understand the runtime behaviour of your program!

My process when debugging a hard bug is:

  1. create a list of hypotheses that could cause the bug
  2. remove all causes from the list that  violate known facts/datapoints
  3. determine what data points you need to collect next to remove additional hypotheses from list 1)
  4. repeat 2) and 3) until you have 1 hypothesis left
  5. prove the remaining hypothesis
  6. fix bug