Trace through example code in class to show and encourage students to debug effectively

  • Demonstrating tracing code in class has the following benefits:
    • Help students get better at reading code and figuring out how it executes
    • Help students spot bugs
    • Show students how useful tracing is, and encourage students to do so at home 
  • You can use a debugger built into your IDE (integrated development environment) to assist students with tracing.
  • Use wrong answers as teaching tools. By tracing through these wrong answers, you can demonstrate exactly where the code fails to execute correctly.
  • For instance,
    • In recursion, tracing can demonstrate possible infinite loops.
    • When it comes to loops, tracing can help keep track of how loops run and how values change.