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

Free lesson

ESP task 3 (3 of 3): Design so others can build it

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

A recipe that says "cook until done"

A recipe that says "cook until done" is no help if you have never cooked.

You send your design to a builder you have never met. You are away. They cannot ask you anything.

If a step says "check the booking", the builder must guess how. If a step says "if the hour is before 9, output Closed", the builder knows.

A good design can be built by a stranger.

Key words

WordWhat it meansExample
SequenceSteps done one after another, in order.ask, check, save
SelectionA choice of path, made by a yes or no answer.if the hour is 21, refuse
IterationDoing steps again and again.for each hour from 9 to 20
LoopCode or a flowchart path that repeats steps.while hour <= 20 (<= means 20 or less)
FlowchartA diagram of steps with arrows.start, check, book
Reusable componentA part you write once and use in many places.price_for()
Sub-systemOne big part of the whole solution.prices, storage, screen
Naming conventionA rule for how names are written, used the same way everywhere.small letters with _ between words, like book_court
Third partyA person outside your team who uses your work.another developer
AudienceThe people who read your design.the manager, the builder

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

The three building blocks of every algorithm

ConstructFlowchart shapeHillside examplePython
SequenceBoxes joined by arrowsInput the hour, then input the court, then saveLines one after another
SelectionA diamond with yes and noIs the hour from 9 to 20?if ... else
IterationAn arrow that goes back upDo this for every hour from 9 to 20for or while

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

Which building block is it?

Have a go

Which building block is it?

5 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

A flowchart with a loop: show the day

flowchart TD
  start([Start]) --> a[Set hour to 9]
  a --> d{Is the hour 20 or less?}
  d -->|yes| o[/Output: the hour and who booked it/]
  o --> n[Add 1 to the hour]
  n --> d
  d -->|no| e([End])

Try it: the same loop in Python

Code: python
names = {10: "Sam", 12: "Aisha"}

hour = 9
while hour <= 20:
    if hour in names:
        print(hour, names[hour])
    else:
        print(hour, "free")
    hour = hour + 1

# The arrow going back up is the while line.
# <= means "is less than or equal to".
# Change 20 to 12 and run it again.

Make a free account to save your work and track your progress.

Check: building blocks

Have a go

Check: building blocks

4 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

A reusable part is written once

The price rule is needed in three places: when a booking is made, when it is cancelled, and in the manager's report.

Do not write it three times. Write one reusable component, price_for, and call it from all three. When the price changes, you change one place.

In a design, draw each reusable part once and show every other part using it.

Sub-systems of the booking tool

flowchart TD
  tool([Booking tool])
  tool --> screen[Screen: forms and messages]
  tool --> rules[Rules: hours and courts]
  tool --> prices[Prices: price_for]
  tool --> store[Storage: the file of bookings]
  screen --> rules
  rules --> store
  screen --> prices

Check: one naming style

Have a go

Check: one naming style

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

Stage 3: turn the loop into code

Turn the loop flowchart into code. booked_hours lists the booked hours in order. day_lines gives one line for each hour from 9 to 20: "10: Sam" or "9: free". free_hours gives the free hours. Use booked_hours inside free_hours, so the idea is written only once. Press Run Tests to check your work.

Code: python
def booked_hours(bookings):
    # bookings is a list like [(10, "Sam"), (12, "Aisha")]: (hour, name).
    # booking[0] is the hour and booking[1] is the name.
    # Give back the booked hours as a list, from the earliest to the latest.
    return None


def day_lines(bookings):
    # Give back 12 lines of text, one for each hour from 9 to 20.
    # A booked hour looks like "10: Sam". A free hour looks like "9: free".
    return None


def free_hours(bookings):
    # Give back the free hours from 9 to 20 as a list, earliest first.
    # Use booked_hours so the idea is written only once.
    return None

Make a free account to save your work, or press Start lab to work through the whole lesson.

Weak steps and strong steps

Weak stepWhy it is weakStrong step
Check the bookingIt does not say howIf the hour is below 9 or above 20, output Closed and stop
Work out the priceWhich price?If the person is a member, the rate is 4. If not, the rate is 6. Price is rate times hours
Save itWhere? In what form?Add one line to the bookings file: name, court, hour

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

Write for the person who reads it

Two people read your design.

The client is the person who asked for the tool. The client wants the main idea, a picture of the screen and what it will cost. Use plain words.

The builder wants every step, every field and every rule. Use the right technical words.

Use both words and diagrams. A diagram shows the shape. Words give the detail.

Stage 3: write a design note

This is stage 3 of the Hillside practice project. Design one new feature: cancel a booking. Part A: write three plain sentences for Mrs Okafor, the client. Say what the feature does and what she will see. Part B: write numbered steps for a builder. Every step does one thing. Use at least one selection and one iteration. Part C: list the names you will use for the function and the data, in one naming style. Part D: say which part you reuse from the rest of the tool.

A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.

Make a free account to save your work, or press Start lab to work through the whole lesson.

Key words crossword

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Final check

Have a go

Final check

5 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

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.