Computer Science I / Debugging Logic and State
Practice question · Put in order

Order the steps of the disciplined debugging routine.

Hints
  1. A bug you cannot reproduce, you cannot reliably fix.
  2. Understanding the cause comes before changing the code, not after.
Show the answer
  1. Reproduce the bug with an input that triggers it every time
  2. Halve the region between a good point and a bad one, repeatedly
  3. Understand why that line produces the wrong value
  4. Fix the code and re-run the reproducing case and the rest of the suite
Why

Reproduce, localize, understand, then fix and verify. Reproducing first is essential: without a reliable trigger you cannot tell whether a later change actually fixed anything. Fixing before understanding is 'shotgun debugging', the pitfall this lesson names.

Read the lesson: Debugging Logic and State →

Practise Debugging Logic and State

The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Debugging Logic and State