Debugging

Lesson 6 - Year 4

Learning Intention

  • I can test and debug my programs

Introduction

Buggy script intended to make Picoh nod three times

Start with the script below. Explain that you wanted to make Picoh nod three times and count. Ask children to predict what it will do.

Teacher Input

Ask children to observe what Picoh does closely when the code runs. Run the script. What does Picoh actually do? How is it different to what we want?

Model going through the code line by line. Ask children to explain line by line in pairs, describing what each block does.

Get children to work in pairs to come up with possible solutions to make Picoh nod. Run children's code suggestions. Explain that they can adopt this approach to debugging their own code.

Activities

1.

Children open up Picoh projects they have written this term. Which work and which could be improved? Can they debug their programs to fix them?

Extension

Can children add extra code to their programs to improve them?

Plenary

Evaluation of the Picoh project. Children to complete the following feedback.

Picoh project evaluation feedback sheet
Ohbot image

Key Points

  • Predicting what code will do before running it helps you spot bugs.
  • Compare what the robot actually does with what you intended.
  • Reading code line by line isolates where the bug is.
  • Explaining code aloud to a partner is an effective debugging technique.

Need Help?

If you're stuck on any part of this lesson, check out these resources:

Ohbot