According to MIT's software course, what should you do first when hunting a bug?
Find a small, repeatable test case that makes the failure happen.
- Rewrite the whole program
- Find a small, repeatable case that triggers it ✔
- Add print lines everywhere at random
Why: If you cannot make the bug happen on purpose, you cannot tell whether a fix worked. A small repeatable case then lets you study the data, form a hypothesis, test it, and repeat, like a scientist.
Huh, didn't know that: Explaining your code out loud, line by line, to an object is called rubber-duck debugging, and it really works.
Debugging is like being a detective in a crime movie where you are also the culprit.
References
Answer: Find a small, repeatable case that triggers it. If you cannot make the bug happen on purpose, you cannot tell whether a fix worked. A small repeatable case then lets you study the data, form a hypothesis, test it, and repeat, like a scientist.
- MIT 6.031 Software Construction, Reading 13: Debugging web.mit.edu/6.031/www/sp22/classes/13-debugging
Start by finding a small, repeatable test case that produces the failure.
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.