Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Top-down, bottom-up and modules

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

40 minutes

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

WordWhat it meansExample
Top-downStart with the whole problem. Break it into smaller and smaller parts.Anna plans the whole video, then films each part
Bottom-upStart with small parts you can build. Join them to make the whole.Ben films clips, then joins them into a video
ModularisationSplitting a program into separate modules. Each module does one job.a login module, a payment module
ModuleA separate part of a program with one job.a file of functions
FunctionA named piece of code that does one job.def area
ReuseUse 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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your 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

Code: python
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.

The lesson goes on

5 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.