Practice question · Sort into groups
Sort each debugging action by whether it reasons from evidence or merely guesses.
Groups: Reasoning from evidence · Debugging by guessing
- Change a comparison because it feels wrong, then re-run
- Set a breakpoint and step through, watching the state
- Rewrite the function from scratch and hope the bug vanishes
- Print the variable's value at the suspect line
Hints
- Ask of each move: does it produce an observation, or only a change?
- A change that might hide a symptom without revealing why is a guess.
Show the answer
Reasoning from evidence: Print the variable's value at the suspect line, Set a breakpoint and step through, watching the state
Debugging by guessing: Change a comparison because it feels wrong, then re-run, Rewrite the function from scratch and hope the bug vanishes
Why
Printing values, stepping through, and narrowing the good-to-bad gap all produce evidence; changing code on a hunch, rewriting blindly, and adding delays produce none. The danger of the guessing moves is that they can hide a symptom while leaving the real cause in place.
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
- A bug appears only in production, never locally, and disappears when logging is added. What class of bug does…
- Select every practice that the lesson recommends for debugging.
- Order the steps of the disciplined debugging routine.
- Systematic debugging narrows down where the state first becomes wrong, rather than reading the code looking…