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
| Word | What it means | Example |
|---|---|---|
| Decomposition | Splitting a big problem into small parts. | booking tool: book, cancel, price |
| Subtask | A small job inside a bigger job. | check the hour |
| User story | One need, told from the user's side. | As desk staff, I want to see the day's bookings |
| Function | A named piece of code that does one job. | cancel() |
| Abstraction | Leaving out details you do not need. | a booking is a name, court and hour |
| Refinement | Adding more detail to a part, one level at a time. | check the hour: 9 to 20 only |
| Dependency | A 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
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 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.