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. Safety is planned from the start. In this lesson you learn to say exactly what the software must do, and to plan safety in from the start.
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 into the software 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 in the software. | 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.
Quick check: do or be?
Have a go
Quick check: do or be?
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Five 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.
Try it: requirements in 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.
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.