Four problems, one choice
Problem 1: a pizza app with many steps. Problem 2: a game with 100 zombies. Problem 3: a library that must remember who has which book. Problem 4: a payment rule that must never be wrong.
Does one design method fit all four? No. A good developer thinks first, then chooses. This is called critical thinking.
Key words
| Word | What it means |
|---|---|
| Function | A small named job in a program. |
| Unit test | A test that checks one small part of the code. |
| Design approach | A way of planning software before and while you build it. |
| Critical thinking | Asking questions, comparing choices and giving reasons for your decision. |
| Top-down design | Splitting the whole system into smaller and smaller jobs. |
| Object-oriented design | Building the program from objects (things that hold data and can act). A class is the plan for making an object. |
| Data model | A picture of the data you need and how it is organised. |
| TDD | Test-driven development. Write a failing test first, then the code. |
| BDD | Behaviour-driven development. Write the wanted behaviour in plain words first. |
| Functional design | Building a program by joining small functions that take values in and give values back, often passing functions to other functions. |
| Project method | The plan for how a team runs a whole project. |
| Waterfall | A project method with steps one after another: plan, design, build, test. |
| Agile | A project method that works in short steps and welcomes change. |
| Sprint | A short, fixed time, often two weeks, in which an agile team finishes some work. |
The cells students fill in are left blank in this preview.
Six approaches at a glance
| Approach | It starts from | Good for | Example |
|---|---|---|---|
| Top-down (function-orientated) | The whole system, split into jobs | A system with many steps and data that moves | A pizza ordering system |
| Object-oriented | The things in the problem | Many similar things that share behaviour | A game with many characters |
| Data model | The data and how it links | Systems that store a lot of linked data | A school library |
| TDD | A failing unit test | Rules that must be exactly right | A fare calculator |
| BDD | A behaviour in plain words | Work with customers who are not developers | A student ticket feature |
| Functional | Small functions | Jobs that change data step by step | Sorting and filtering a list |
The cells students fill in are left blank in this preview.
Match the problem to the approach
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Approaches work together
The approaches do not compete. One project often uses several.
A game team may plan the whole game top-down. They use classes for the characters. They draw a data model for scores and players. They write tests first for the scoring rules.
You choose by asking questions about the problem.
Questions that help you choose
flowchart TD
start([A new problem]) --> q1{Is there a lot of linked data to store?}
q1 -->|yes| dm[Draw a data model]
q1 -->|no| q2{Are there many similar things?}
dm --> q2
q2 -->|yes| oop[Use object-oriented design]
q2 -->|no| td[Split the system top-down]
oop --> q3{Must a rule be exactly right?}
td --> q3
q3 -->|yes| tdd[Write tests first: TDD]
q3 -->|no| bdd[Describe the behaviour first: BDD]
Three approaches in one program
# A data model: a dictionary of prices
MENU = {"pizza": 8, "chips": 3}
# Function-orientated design: one small job
def total(items):
cost = 0
for item in items:
cost = cost + MENU[item]
return cost
# Object-oriented design: a class
class Order:
def __init__(self, items):
self.items = items
def cost(self):
return total(self.items)
# Test-driven: the test says what we want
def test_cost():
assert Order(["pizza", "chips"]).cost() == 11
test_cost()
print("The test passes")
Make a free account to save your work and track your progress.
Which approach fits?
Have a go
Which approach fits?
5 questionsDesign inside a project method
Every team also has a project method. It decides when design happens.
In waterfall, you design once, before you build. A wrong choice costs a lot later.
In agile, you design a little in every sprint. TDD and BDD fit well, because tests and behaviours are small and can change.
Waterfall and agile: when do you design?
| Waterfall | Agile | |
|---|---|---|
| Design happens | Once, near the start | A little in every sprint |
| If the customer changes their mind | Hard and expensive | Normal. Change the next sprint |
| Approach that fits well | Top-down design and a full data model | TDD, BDD and small steps of any approach |
| Risk | A mistake in the design is found late | No overall plan if nobody keeps one |
The cells students fill in are left blank in this preview.
Sort the problems by approach
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Choose the approaches for a project
A sports club wants an app. Players see match times. Parents book places and pay. The coach adds results. The club has four students who will build it in six weeks, in three sprints. Choose three design approaches for this project. For each one, say which part of the app it helps with and why. Then say whether you would use waterfall or agile, and give one reason.
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.
Exit quiz
Have a go