Three Quick Debugging Tips That Saved My Day

1. The Rubber Duck Method Works

I used to think it was silly. Then I actually tried it.

Explain your code to an inanimate object (or a patient colleague). The act of verbalizing your problem often leads to the solution.

2. Binary Search Your Code

Instead of checking everything at once:

  1. Comment out half your code
  2. Does the bug still exist?
  3. If yes: the bug is in the uncommented half
  4. If no: the bug is in the commented half
  5. Repeat until you find it

This is surprisingly effective and much faster than random guessing.

3. Check Your Assumptions

90% of bugs come from incorrect assumptions:

  • "The API must be returning..." → Check it
  • "This variable can't be null" → Verify it
  • "The loop is running" → Add a log statement

Write down what you think is happening, then prove each assumption with evidence.

TL;DR

  • Talk to a duck (or colleague)
  • Binary search your code
  • Never assume - always verify

Debugging doesn't have to be frustrating. Sometimes it's just about having the right approach.

Share this post