Debugging — Year 2 Lesson Plan
National Curriculum: Computing KS1 — create and debug simple programs; use logical reasoning to predict the behaviour of simple programs
Overview
Pupils learn to identify and correct errors ('bugs') in sequences of instructions. Through logical reasoning, they practise predicting what a program will do, spotting where it goes wrong, and fixing it systematically. This lesson develops resilience, logical thinking, and the understanding that errors are a natural part of programming.
Learning Objectives
- Understand what a 'bug' is in a program.
- Use logical reasoning to find where a sequence goes wrong.
- Correct bugs in a sequence and test the fix.
- Develop persistence when programs do not work as expected.
Key Vocabulary
Suggested Lesson Structure
Present a deliberately wrong algorithm on the board (e.g. instructions for brushing teeth: 'Put on shoes. Open toothpaste. Brush teeth. Eat breakfast. Rinse.'). Can pupils spot what's wrong? Introduce: finding and fixing mistakes is called debugging.
Open a pre-built buggy program in ScratchJr/Scratch or a Bee-Bot route card with an error. Narrate the debugging process: 'I predict this should go right — but it went left. Let me look at step 3… ah, the block says left, not right. I'll change it and test again.' Emphasise: debugging is not failing; every programmer debugs. Even professional programmers debug constantly.
Provide pupils with 'buggy' route cards or printed sequences. In pairs, they: predict what the sequence will do, run it (or trace it by hand on a grid), identify the bug, fix it, and test again. Record: what was the bug? How did they find it?
Pupils create a short program in the class tool (ScratchJr/Bee-Bot) and deliberately introduce a bug for their partner to find. Partner debugs and describes how they found it. Swap.
Discuss: what strategies did you use to find bugs? (e.g. check from the start, run one step at a time). What did you do when you were stuck? Connect to real-world debugging: even the programs on our tablets and phones had bugs that needed fixing before they were released.
Common Misconceptions
- Pupils sometimes think bugs mean they have 'failed' — emphasise that debugging is a skill all programmers use, not a sign of getting something wrong.
- Trying to fix everything at once — good debugging means changing one thing at a time and testing each change.
Prior Knowledge
Pupils should already be able to:
- Experience creating and running sequences of instructions.
- Familiarity with the programming environment being used.
Want a personalised version of this lesson?
Use Staffroom to generate a complete lesson plan tailored to your class — add context about ability, recent learning, or specific pupils and get a plan ready to teach. Free trial, no card required.