3 of 1 ·Fix and improve

Lesson 3 · Computational Thinking
Repairing and making it better.
Debugging Detective
A bug makes instructions produce the wrong result. Write what you expected, compare what happened, and change one step. Run the same example again to check your fix.
Click to zoomFinding it is only half the jobYou've located the bug. Now comes the part people rush — and rushing here creates new bugs.
A proper fix has three parts:
That third point is the one beginners skip. Fixing one thing and quietly breaking two others is the most common way programs fall apart.
Click to zoomTreat the cause, not the symptomSuppose your game shows a score of -1. You could add a rule: "if the score is -1, show 0."
The symptom disappears. The bug is still there — and tomorrow it'll show -2.
A symptom fix patches what you see. A cause fix asks why the score went negative at all, and repairs that. Symptom fixes pile up until nobody can understand the program any more. Ask "why" until you reach something that actually explains the behaviour.
7 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.