AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Fix the story

Week 26 · Unit 10: Be a storyteller · 3 lessons
1

Debug step by step

Computing 2: Unit 10, pp. 134–148
GoalUse clear steps to find and fix a bug in a program.
New words
bug · a mistake in a programdebug · to find and fix bugsfix · to change something so that it is right
Explanation

Debugging has steps. Run the program and watch it. Compare what happens with the algorithm. Find the block that is different. Fix that block. Then run the program again. Fix one bug at a time, so that you know what each change does.

run itcomparefix one bugrun again
Worked examples
Woof!2
The algorithm for the dog is: start on green flag, move right 2, say “Woof!”, stop. When we run the program, the dog says “Woof!” first and then moves. The order is wrong.
2
A child taps the character and nothing happens. The program starts on the green flag, but the algorithm says to start on tap. The first block is the bug.
BugFixed?
1 the order is wrongyes
2 the number is wrongnot yet
A program has two bugs. We fix the first one, run the program, and then fix the second one. We keep a list and tick each bug when it is fixed.
Class activity

Dance bugs: a grown-up writes a dance algorithm on paper: clap 2, stamp 3, turn around once, wave. One child performs the dance from cards that have two mistakes, for example clap 3 or the wrong order. The others follow the algorithm and shout “Bug!” when they see a difference. Then fix the cards and dance again.

Practice
1
The algorithm is: start on tap, move right 3, hop 2, stop. When we run the program, the character moves right 3 and hops 1. Which block has the bug and how do we fix it?
31
2
Put the debug steps in order: A fix it, B run the program, C compare with the algorithm, D find the block that is different.
3
Why should we fix only one bug at a time?
4
The algorithm is: start on green flag, move down 2, say “Hi!”, stop. How many bugs does this program have? What are they?
3Hi!