Lesson 41: Break it down
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
One big job, many small jobs
- A big problem is easier when you break it into smaller parts: decomposition.
- A structure diagram shows the parts. The top box is the whole job; each box under it is a smaller job.
- In the program, each box becomes a procedure.
Words for this lesson
| Word | Meaning |
|---|---|
| decomposition | breaking a problem into smaller parts |
| structure diagram | a diagram of the parts and sub-parts |
| sub-procedure | a procedure that does one part of a bigger job |
The structure diagram
- main: draw the picture
- draw_house
- draw_walls
- draw_roof
- draw_fence
- draw_post (3 times)
- draw_house
In the exam
- 0478/21/O/N/23 Q5(b): identify three component parts of a problem after decomposition. Mark scheme: inputs, processes, outputs, storage.
- 0478/22/F/M/23 Q5: complete a structure diagram for a food ordering system: each part is split into smaller parts, as in the diagram above.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
Draw a house and a fence with the pen. The job is broken down into parts, like the structure diagram on this page: draw_house uses draw_walls and draw_roof. Write those two procedures. The robot then goes on to draw the fence.
Click Run to see the output here.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
Now the other branch of the diagram: draw_fence uses draw_post three times. Write draw_post (left 90, up 200 mm, back 200 mm, right 90, then 150 mm on to the next post) and draw_fence.
Click Run to see the output here.