3
Debug a whole project
Computing 2: Unit 6, pp. 80–91
GoalCheck a project with two characters one script at a time and fix its bugs.
New words
project · a bigger program that you plan and makescript · the blocks of one charactertest · to run a program to see if it works
Explanation
A project can have more than one character. Each character has its own script. Check one script at a time. Compare it with its algorithm. Is the start block the right one? Are the blocks and numbers right? Fix one bug, then run the whole project again. Keep testing until you cannot find any more bugs.
Worked examples
The algorithm for the duck says: start on bump, say “Quack!”, grow 1, end. But the duck’s script starts on the green flag. The duck quacks at the beginning and not when the frog bumps it. The start block is the bug.
After the fix, the duck starts on bump. The frog moves right until it bumps the duck. Now the duck says Quack! and grows. The team runs the project again to test it.
To check a route, count the squares. The rabbit goes right 2, then down 3, then right 1. It moves 2 + 3 + 1 = 6 squares.
Class activity
Project debug in pairs: each partner writes algorithms for two characters on paper. Character 1 starts on the flag and walks to a toy on a floor map. Character 2 starts on bump, says something and hops. Each partner draws the block cards for the project but hides one mistake in one of the scripts. Swap. Compare each script with its algorithm and find the mistake. Fix it and “run” the project with your bodies to test it.
Practice
1
The algorithm says the fish starts on bump. Which block is the bug and what must it be?
The start on tap block. It must be start on bump.
2
The algorithm for the frog says: right 2, up 2, right 2. Find the bug in the program. How many squares should the frog move in all?
The up 1 block is the bug. It must be up 2. The frog should move 2 + 2 + 2 = 6 squares.
3
A tester runs a project and the frog moves too far. What should the tester do next?
Compare the frog’s blocks with its algorithm, fix the wrong number, and run the project again.
4
Why do we run the project again after a fix?
The fix might not be right, or there might be another bug. Testing again checks both.