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

Break it into parts

Week 24 · Unit 10: Be a game developer · 3 lessons
3

Errors teach us

Computing 3: Unit 10, pp. 147–160
GoalTest a program, find an error and say what the error taught you.
New words
error · a mistake in an algorithm or a programtest · to run a program and see what happensexpected result · what the algorithm says should happen
Explanation

Everybody makes errors, even game developers. We test a program to find them. We run it and compare what happens with what the algorithm says should happen. Sometimes a number box is empty. In Scratch an empty number box counts as 0, so nothing seems to happen. Sometimes the wrong block or the wrong number is used. When we find an error, we fix it and test again. We also say what we learned, such as “always fill every number box”. That helps us not to make the same error again.

whenup arrowkey pressedchange y by
Worked examples
Algorithm saysThe program doesError
change y by 20change y by (empty)the number box is empty
The algorithm says: when the up arrow key is pressed, change y by 20, so the sprite moves up. The program here has an empty number box. We press the up arrow and the sprite stays where it is. The box counts as 0, and 0 changes nothing. We type 20 in the box and test again.
Kind of errorExampleWhat we see
empty number boxmove ( ) stepsthe sprite does not move
wrong numbermove (1) steps, not 100the sprite hardly moves
wrong blockthink, not saya thought bubble, not a speech bubble
no hat blocka loose move blocknothing starts
Errors come in different kinds. Each kind has its own clue.
The errorWhat I learned
an empty number boxcheck that every number box has a number
no hat blockstart every script with a hat block
Keep an error log. It is a short list of what went wrong and what you learned. Your next programs will have fewer errors.
Class activity

Error detectives (in pairs): one of you writes a three-step algorithm on a card, for example “1 Stand up. 2 Take 3 steps forward. 3 Clap twice.” On another card the same person writes the program but puts in one hidden error, such as “Take 2 steps” or a missing step. The detective acts out the program, compares it with the algorithm and finds the error. Then the detective writes one sentence: “I learned …”. Swap roles.

Practice
1
The algorithm says: when the green flag is clicked, say “Hello!” for 2 seconds. Test the program. What is the error?
whenclickedsayHello!forseconds
2
The algorithm says: when the sprite is clicked, say “Welcome!” for 2 seconds. What is the error in this program?
when this sprite clickedthinkWelcome!for2seconds
3
A move block is lying alone on the scripts area with no hat block. What happens when you click the green flag?
4
Ravi finds that his program did nothing because a number box was empty. Write one sentence about what he learned.