Buy the lock after the robbery?
A shop is robbed. The owner then buys a lock. That is too late.
A wise owner plans the lock when the door is made.
Software works the same way. You plan safety from the start. In this lesson you say exactly what the software must do, with safety planned in.
Key words
| Word | What it means | Example |
|---|---|---|
| Functional requirement | Something the software must do. | The user can pay by card. |
| Non-functional requirement | How well the software must work, not what it does. | It loads in 3 seconds. |
| Secure by design | Planning safety in from the very start. | check every input from the start |
| Input | Data that goes into the software. | a name typed in a box |
| Processing | What the software does with the data. | add up the prices |
| Logic | The rules and decisions the software follows. | if the total is 50 or more, delivery is free |
| Platform | The device or system the software runs on. | Android phone, web browser |
| Requirement | Something the software must do or be. | pay by card |
The cells students fill in are left blank in this preview.
Check: what it does or how well
Have a go
Check: what it does or how well
3 questionsFive parts of a functional requirement
| Part | The question | Cinema ticket app |
|---|---|---|
| Inputs | What goes in? | Number of adults and children, a date, an email address |
| Data needed | What facts must be stored or looked up? | Ticket prices, film times, booking numbers |
| Processing | What is done with the data? | Add up the cost, check there are enough free seats |
| Logic | What rules and decisions apply? | Groups of 10 or more get a discount |
| Platforms | Where is it used and run? | On phones and in a web browser; runs on a cloud server |
The cells students fill in are left blank in this preview.
Which of the five parts is it?
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Requirements become lines of code
adults = 2
children = 3
# Input: adults and children
# Data needed: the two prices
adult_price = 8
child_price = 5
# Processing: add up the cost
total = adults * adult_price + children * child_price
# Logic: a group of 10 or more gets 10 pounds off
if adults + children >= 10:
total = total - 10
print(total)
# Change adults to 6 and children to 6, then run it again.
Make a free account to save your work and track your progress.
Secure by design
Secure by design means you ask "what could go wrong?" while you write the requirements. You do not wait for a hacker.
It changes the requirements you write. You decide who may see what. You decide that every input is checked. You decide to store only the data you really need.
Security thinking turns into requirements
| Question while planning | Requirement that follows |
|---|---|
| What if somebody types something harmful? | Every input is checked before it is used. |
| Who should see a customer's details? | Only the customer and named staff can see them. |
| What if the password is guessed? | After 5 wrong tries, the account is locked for 10 minutes. |
| Do we need the date of birth? | No. Do not collect data we do not need. |
| What if the data is stolen? | Passwords and card details are never stored as plain text (text that anybody can read). |
The cells students fill in are left blank in this preview.
Turn three requirements into code
Write the function for the cinema ticket app. Follow the three requirements in the comments. R1: the two prices. R2: the group discount. R3: bad input gives back None. Press Run Tests when you are ready.
def ticket_total(adults, children):
# Requirements for a cinema ticket:
# R1. An adult ticket costs 8 pounds. A child ticket costs 5 pounds.
# R2. A group of 10 people or more gets 10 pounds off the total.
# R3. Bad input: if adults or children is below 0, give back None.
return 0
Make a free account to save your work, or press Start lab to work through the whole lesson.
A good requirement is clear and testable
Tip
Bad: "The app should handle a group."
Good: "A group of 10 or more gets 10 pounds off the total."
A tester can check the second one. Nobody can check the first.
Write the requirements for a trip app
A school wants an app for booking a school trip. Parents choose a trip, say how many children go, and pay.
Write the functional requirements. Use these five headings.
- Inputs (at least three):
- Data needed (at least two):
- Processing (at least two):
- Logic (at least two rules):
- Platforms:
Then write two requirements that come from secure by design thinking.
Example for Logic: "If a trip is full, the parent sees a message and cannot book."
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