Back to Bug Lab

Defect localization · Hypothesis testing

Bug Detective

Find the bug by reasoning, not guessing. The under-taught skill in programming.

Inspect this small program that does the wrong thing. Find the bug by stepping through what each line actually does and comparing it to what you expected it to do. The discipline this builds — narrowing down where reality and assumption diverge — is what separates good debuggers from people who 'try things' until something works.

Bug Detective

Find the mistake in each program

Puzzle 1 of 5

The Goal

Draw a blue square

The Result (something is wrong)

Draws a red square instead of blue

The Program — click the buggy step

What you just learned

Every program has bugs — mistakes that make it do the wrong thing. Debugging is the skill of reading carefully, comparing what should happen to what actually happens, and finding the difference. Professional programmers spend more time debugging than writing new code.

What’s happening under the hood

  • Scientific method applied to code: form a hypothesis ('I think X is broken'), test it by inspecting that exact thing, narrow the search space.
  • Print debugging is real debugging. So is rubber-duck explanation. The cheapest tool that surfaces the bug wins.
  • Modern debuggers (lldb, Chrome DevTools, IDE-integrated debuggers) automate the inspection — but the hypothesis-testing discipline is still on you.

Dig deeper

Phase 1 · Debugging

The concept you just explored is taught with full depth in the formal DURA curriculum.