Debugging: finding what went wrong
Computer Science · Key Stage 1 · The School
A bug is a mistake in the instructions
When a program does not do what you wanted, there is a BUG — a mistake in the instructions. The computer is not being naughty and it has not misunderstood. It did exactly what the instructions said, which turned out not to be what you meant.
Find the step
Do not start again from the beginning. Run the instructions slowly and watch: which step was the first one that went wrong? Everything before that was fine. Looking only at that step and the one before it is far quicker than reading everything again.
Change one thing
Change ONE thing, then run it again. If you change three things at once and it works, you do not know which one fixed it — and if it still fails, you do not know which change made things worse. One change, one test, every time. This is exactly how professional programmers work.
A sprite should move right and turn, but it spins on the spot. Do not change three blocks at once. Change ONE: swap 'turn 15 degrees' for 'turn 90'. Run it. Still spinning. Change it back, and move the 'turn' block AFTER the 'move' block instead. Run it. Fixed. You now know what the bug was, which random fiddling would never have told you.