beginner · 27 minute study
Turn a failure into a controlled experiment
Learn to diagnose a defect from evidence instead of changing code until the warning disappears.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- Model allowed changes, not just stored fields — Both a game and an order workflow need to know which actions are valid now. Explicit transitions make invalid combinations harder to create.
First, build a mental model
An error is an observation, not yet an explanation. Reduce the uncertainty with a reproducible case, a specific hypothesis and a test that could prove that hypothesis wrong.
- Observe the exact symptom and the conditions in which it appears; distinguish the first error from later consequences.
- Reproduce with a small fixture so the same input reliably demonstrates the problem.
- Trace actual values at the boundary where the behavior first diverges from the requirement.
- Change one relevant cause, then rerun the reproduction and neighboring cases.
- Add a regression test for the intended behavior. A suppressed exception is not evidence that the underlying operation became correct.
const lines = [{ quantity: 2 }, { quantity: 3 }];
let units = 0;
for (let index = 0; index <= lines.length; index++) {
units += lines[index].quantity;
}
console.log(units);- Index 0
Read quantity 2 and add it to units.
- Index 1
Read quantity 3 and reach units = 5.
- Index 2
The condition still permits 2, but lines[2] is undefined. Reading quantity fails before the final output.
Production thinking
Take this beyond the example.
Keep diagnostic logs useful and sanitized. Avoid pasting secrets or customer data into debugging tools. An AI explanation is a hypothesis until the reproduction and tests support it.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · One thread can still have overlapping operations →