Two ways to make a video
Anna wants to post a video. First she plans the whole video: the start, the middle and the end. Then she films each part.
Ben films short clips all week: a trick shot, a funny moment, a goal. Then he joins the best clips and sees what video they make.
Both ways work. Which way do you work? Programmers use both.
Key words
| Word | What it means | Example |
|---|---|---|
| Top-down | Start with the whole problem. Break it into smaller and smaller parts. | Anna plans the whole video, then films each part |
| Bottom-up | Start with small parts you can build. Join them to make the whole. | Ben films clips, then joins them into a video |
| Modularisation | Splitting a program into separate modules. Each module does one job. | a login module, a payment module |
| Module | A separate part of a program with one job. | a file of functions |
| Function | A named piece of code that does one job. | def area |
| Reuse | Use a part again in a new place. | the same login in two apps |
The cells students fill in are left blank in this preview.
Top-down in words
Top-down starts at the top. You first decide what the whole thing must do. Then you break each part into smaller parts, again and again, until each part is easy to build.
It is a good choice when you know the goal and the problem is big.
Bottom-up in words
Bottom-up starts at the bottom. You build small parts you already know how to make. You test each one. Then you join them to make something bigger.
It is a good choice when you have good parts already, or when you are not sure what the whole will be.
Top-down or bottom-up?
Have a go
Top-down or bottom-up?
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Modularisation
Modularisation means splitting a program into modules. Each module has one job and clear inputs and outputs.
Other parts of the program use a module without knowing how it works inside. You can test a module alone. You can reuse it in another program.
Try it: use a module
import math
print(math.sqrt(16))
print(math.pi)
# math is a module that other people wrote.
# You use it without seeing how it works inside.
# Change 16 to 25 and run it again.