Lesson 4: Splitting a big job into parts

Unit overview - Previous: Lesson 3 - Next: Lesson 5

About 45 minutes.

Goal

Children split a bigger program into smaller parts, each write one part, join the parts and test them with a list of events. They test one part at a time to find which part has a bug.

Materials

Steps

Opening (5 min)

  1. Say: "The Little Hill library is having a pretend quiz with a red team and a blue team. Each team has a button. The library wants a program that keeps both scores."
  2. Put up the job description:
  3. At the start, both scores are 0.
  4. When the red button is pressed, red gets 1 more.
  5. When the blue button is pressed, blue gets 1 more.
  6. At the end (the bell), both scores are said.
  7. Say: "That is a big job. Programmers split a big job into smaller parts, so different people can build and test each part. This is called decomposing the problem."

Main activity (30 min)

Part 1: name the parts (5 min). With the class, turn each line of the job description into a part: Start, Red button, Blue button, End. Each child in a group of four takes one part.

Part 2: write the parts (8 min). Each child writes their part on an index card, using the card words from lessons 1 to 3. One correct set:

Part 1 (Start)
WHEN QUIZ STARTS:
    SET red TO 0
    SET blue TO 0

Part 2 (Red button)
WHEN RED BUTTON:
    CHANGE red BY 1

Part 3 (Blue button)
WHEN BLUE BUTTON:
    CHANGE blue BY 1

Part 4 (End)
WHEN BELL:
    SAY red
    SAY blue

Other wordings that do the same job count.

Part 3: test each part, then join (9 min). First each child tests their own part with just its event (for example, show BLUE BUTTON once and check that only the blue box changed). Then the group lays the four cards side by side and runs the test list:

QUIZ STARTS, RED BUTTON, BLUE BUTTON, RED BUTTON, RED BUTTON, BELL.

Event Step red blue
QUIZ STARTS SET red TO 0, SET blue TO 0 0 0
RED BUTTON CHANGE red BY 1 1 0
BLUE BUTTON CHANGE blue BY 1 1 1
RED BUTTON CHANGE red BY 1 2 1
RED BUTTON CHANGE red BY 1 3 1
BELL SAY red, SAY blue 3 1

(Says red 3, blue 1.)

Part 4: a bug in one part (8 min). Show this version of Part 3:

Part 3 (Blue button)
WHEN BLUE BUTTON:
    CHANGE red BY 1

Run the same test list. (Red 4, blue 0, instead of red 3, blue 1.) Ask: "Which part would you test first?" (The blue button part, because the blue score never changed.) Show BLUE BUTTON alone: the red box changes, so the bug is in Part 3. Fix it to CHANGE blue BY 1 and run the list again. (Red 3, blue 1.)

Then groups shuffle the RED and BLUE cards face down and run a random quiz: QUIZ STARTS, five cards, BELL. The check is that the trace matches the cards.

Discussion questions (with answers) (5 min)

Closing check (with answers) (5 min)

  1. "QUIZ STARTS, BLUE BUTTON, BLUE BUTTON, RED BUTTON, BELL. What is said?" (Red 1, blue 2.)
  2. "Part 1 is missing. From an earlier quiz, the boxes hold red 3 and blue 1. Then RED BUTTON, BELL. What is said, and what should it be?" (Red 4, blue 1; it should be red 1, blue 0.)
  3. "Name the four parts of the quiz program." (Start, Red button, Blue button, End.)

Vocabulary

decompose, part, test, join, two variables

Differentiation

Safety

Teacher notes and misconceptions