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

Preview

Break a big problem into small jobs

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

Lunch for 30 people

You must make lunch for 30 people by 12 o'clock. It feels too big.

So you split it: make a shopping list, buy food, cook, serve, clean up. Each job is small. Each job has one owner.

Developers do the same with a big brief.

Key words

WordWhat it meansExample
DecompositionSplitting a big problem into small parts.booking tool: book, cancel, price
SubtaskA small job inside a bigger job.check the hour
User storyOne need, told from the user's side.As desk staff, I want to see the day's bookings
FunctionA named piece of code that does one job.cancel()
AbstractionLeaving out details you do not need.a booking is a name, court and hour
RefinementAdding more detail to a part, one level at a time.check the hour: 9 to 20 only
DependencyA job that must finish before another starts.design before build

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

How small is small enough?

A good piece is small enough to do in one sitting. It does one thing. You can test it alone.

Ask: "Can I say what this piece does in one short sentence?" If you cannot, split it again.

Refine: add detail in rounds

Do not write every detail at once. Work in rounds. This is refinement.

Round 1: "Make a booking." Round 2: "Check the hour, check the court, save." Round 3: "The hour must be from 9 to 20."

Each round adds detail and hides nothing. Write one line on why you split the problem that way. A marker rewards a reason for the split, not only the split.

Try it: each part is a function

Code: python
def check_hour(hour):
    return hour >= 9 and hour <= 20


def price_for(is_member, hours):
    if is_member:
        rate = 4
    else:
        rate = 6
    return rate * hours


print(check_hour(10))
print(check_hour(21))
print(price_for(True, 2))

# Call price_for for a visitor for 3 hours.

User stories: needs from the user's side

A user story is one sentence. It has three parts: who, what, why.

"As a desk worker, I want to see all of Saturday's bookings, so that I can tell a caller which hours are free."

One story is one need. Stories are easy to test.

Quick check: splitting a problem

Have a go

Quick check: splitting a problem

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

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

The lesson goes on

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