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 design and data flow

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

One pizza order, many jobs

You order a pizza on your phone. Many things happen before it arrives.

Someone checks the menu. Someone adds up the cost. Someone tells the kitchen. Someone prints the receipt.

A big system is not one big job. It is many small jobs. Today you learn how to plan them.

Key words

WordWhat it meansExample
Top-down designStart with the whole system. Then split it into smaller parts.Pizza app, then Take order
Function-orientated designAnother name for top-down design. The system is built from functions.
FunctionA small job in a program with a name. It takes data in and gives data out.order_total()
Sub-systemA smaller part of a bigger system.The kitchen screen
Divide and conquerBreak a big problem into small problems you can solve one by one.
Data flowThe way data moves from one part to the next.
Data flow diagramA picture that shows each job and the data that moves between them.DFD

The cells students fill in are left blank in this preview.

Start at the top

In top-down design you start with one big box: the whole system.

Then you ask: what jobs must it do? Each job becomes a smaller box. Then you split those boxes again. You stop when each box is one simple job.

Each simple job becomes one function in the code.

Quick check: top-down

Have a go

Quick check: top-down

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.

Follow the data

A system is not only a list of jobs. Data moves between the jobs.

The order goes from the customer to the cost job. The cost goes to the receipt job. This movement is the data flow.

A data flow diagram (DFD) draws the jobs as boxes and the data as labelled arrows.

Try it: data flows through functions

Code: python
def add_up(prices):
    return sum(prices)


def add_fee(total):
    return total + 3


prices = [8, 3, 2]
food = add_up(prices)
pay = add_fee(food)
print("Food", food)
print("Pay", pay)

# Each function is one box. The variables are the arrows.
# Change the prices and run again.

The four parts of a DFD

PartWhat it isExample
External entityA person or system outside your systemCustomer
ProcessA job that changes data. Name it with a verbAdd up food
Data storeWhere data waits until it is neededMenu prices
Data flowAn arrow that carries data. Name it with a nounfood total

The cells students fill in are left blank in this preview.

The lesson goes on

6 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.