The big ideaA long program is built from small parts. Run each part as you build it.
How it works
A long program is built from small parts, joined end to end.
Give each part a name and one job, so each is easy to understand.
Run each part as you build it, so a bug has fewer places to hide.
Run a part, check it, then add the next. Fix one bug at a time.
Mina's way of building.
Example 1: Too much at once
Mina snaps on all twenty blocks and presses Go without checking a single part.
One step is mixed up, so Bo sets out candles but forgets the cake.
Finding one bug in twenty steps takes forever.
Example 2: Cut it into parts
Teo cuts the long strip into four short parts: fetch, carry, decorate and celebrate.
Each part has a name and one job.
A long program is just small programs joined end to end.
Example 3: Run a part, check it
Mina runs part one alone, and Bo fetches the cake, so she keeps that part.
Part two has a bump, but it holds only six steps, so it is quick to check and fix.
Then she adds the next part.
Example 4: The order matters
The program has six steps: fetch the cake, carry it to the table, put the candles on, switch the candles on, switch the room lights off and play the song.
The candles must glow before the room goes dark.
So switch the candles on comes just before switch the room lights off.
Bo's birthday program, in order.
Words to know
part
A small piece of a long program, with a name and one job.
bug
A mix-up in a program that you can fix.
run
To make the program go, to see what it does.
Watch out
Do not write it all and run it only at the end. Bugs hide among many steps.
Do not skip checking because it is probably fine.
Do not change ten things at once. Change one, so you know what worked.
Do not leave a part without a name. A name and one job keep it clear.
Try it
Mina's program has twenty steps and she has run none of them. Will a bug be easy or hard to find?
What do you do right after a part works?
How many things should you change when you fix a bug?
Which comes first in Bo's birthday program: carry the cake to the table or put the candles on?
A long program is small programs joined end to what?
Answers: 1. Hard · 2. Check it, then add the next part · 3. One · 4. Carry the cake to the table · 5. End
Try at homePick a long job, like making breakfast or tidying a room. With a grown-up, split it into four short parts and give each part a name, then do part one and check it before you start part two.
For grown-upsDo the Mission: pick a long job like making breakfast or tidying a room, split it into four short parts together and give each a name. Do part one and check it before you start part two.
Open these notes on screenScan the code, or go to tutorpip.com.