Teaching article
Debug the first wrong state, not just the final destination
Locate the first mismatch between intended and actual position.
A route may end far from its goal because of one early turn. Trace the commands in order and locate the first mismatch, giving the repair a specific target instead of repeatedly changing the last instruction.
Compare expected and actual states after each command. Repairing the first divergence is more informative than repeatedly guessing a final correction.
Find where the expected and actual paths diverge
- Trace commands slowly.
- Mark the first divergence.
- Replace one command.
An incorrect turn at command three explains later wrong squares.
Changing the final step may hide the earlier error. Where did the first mismatch occur?
Use a trace table.
Resources
- Human Robot Commands – Coding Without Screens Printable Game — Check the command conventions before using the sequence or debugging task.
Further reading
- CS Unplugged — Kidbots and algorithm activities
- Australian Curriculum Version 9 — Technologies overview
Read next
- A loop repeats the whole block inside it
- Two-state cards need a shared convention
- Trace a program through its intermediate states
Explore Coding and computational thinking. Browse all teaching articles.
