LightMySky

Debugging as a Method: Reproduce, Isolate, Fix

Working from a fault to its cause by a repeatable route: reproduce it reliably, cut the program down until the fault is cornered, then change one thing and check. Guessing edits is the habit this replaces.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Turn a vague fault report into a repeatable set of steps that shows it every time
  • Narrow a bug down by halving the suspect region rather than reading the whole file
  • State a hypothesis about the cause, then design the one check that would refute it

1 · Read

You start every fix with a reproduction: steps that show the fault every single time. You rerun the program the same way, then shrink to the smallest input that still triggers it. A tiny failing case beats a hundred guesses because you can rerun it after each change.

Try it together

You isolate by halving the suspect region: switch off half the code and see if the fault stays. You can also rewrite the suspect block as plain steps and trace it by hand with the failing input. When your hand trace and the machine disagree, you have found the exact line where your model breaks.

You then state a hypothesis: a claim about the cause plus the one check that would prove it wrong. You change one thing, rerun the reproduction, and compare. Keeping notes on each try builds your personal bug catalogue, and old faults start looking familiar.

Good to know

You only edit once the fault is cornered to one line, and you verify by rerunning the reproduction. Guessing edits without reproducing leaves you unable to tell whether any change fixed anything.

Reproduce every time, halve to one line, change one thing and rerun.

More to read

3.2 Algorithm Design and Discovery

Every fix starts with a plan, not an edit. You state the steps that trigger the fault, then you shrink the suspect area bit by bit until one line is left. That is algorithm design turned inward: break a big confusing problem into smaller checks you can actually run. Each check should rule something out, so even a failed guess teaches you where the bug is not.

4.2 Building C Programs

A program fails in your logic or in how you run it. Before blaming the code, rerun it the same way and confirm the fault still shows. Then shrink to the smallest input that still triggers it. A tiny failing case is worth more than a hundred guesses, because you can rerun it after every single change.

How to Start Learning Computer Programming: Ultimate Guide

New programmers often change five things at once and hope. The disciplined habit is slower but faster: read the error, form one idea about the cause, and test that idea alone. Keep notes on what you tried and what happened. Over time those notes become your personal bug catalogue, and faults you once feared start looking familiar.

AP CSP exam pseudocode reference

Pseudocode strips a program to its bare logic, which makes it a fine tool for cornering bugs. Rewrite the suspect block in plain steps and trace it by hand with the failing input. When your hand trace and the machine disagree, you have found the exact line where your mental model breaks. That disagreement is the hypothesis you then verify with one run.

Explore more

2 · Watch

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Debugging as a Method: Reproduce, Isolate, Fix · Computing, ages 17 to 18 · LightMySky