Plan the house before you build it
Nobody builds a house by laying bricks and hoping. They draw plans first.
Software needs plans too. You draw the screens. You plan the steps. You plan the data.
Today you also meet a new helper: an AI tool that can write code. It is fast. But you must check every line.
Key words
| Word | What it means | Example |
|---|---|---|
| Interface | The part of the software that a user sees and touches. | screens and buttons |
| Wireframe | A simple drawing of a screen, with no colour or pictures. | boxes for the logo and the menu |
| Algorithm | A list of steps that solves a problem. | how to work out the order total |
| Flowchart | A picture of steps joined by arrows. | start, add up the food, show the bill |
| Function | A named block of code that does one job. | delivery_fee |
| Licence | Permission, with rules, to use something that somebody else made. | free to copy, but you must say who made it |
| Data requirement | What facts the software must store, and what kind each one is. | name: text; price: a number |
| Generative AI | A tool that makes new text or code from a request you type. | a chat tool that writes a function |
| Prompt | The request you type to a generative AI. | Write a function for a delivery fee. |
| Review | To read and check work made by somebody else or by a tool. | check the code against the list of requirements |
| Requirement | Something the software must do or be. | Delivery is free at 20 pounds or more. |
The cells students fill in are left blank in this preview.
Quick check: design words
Have a go
Quick check: design words
3 questionsThree things to design
| Design | What you make | Pizza app example |
|---|---|---|
| Interface | Wireframes of each screen | The order screen: pizza list, size buttons, total, Pay button |
| Algorithms | Flowcharts or step lists | Steps to add up the basket and the delivery fee |
| Data | A table of the facts to store | Customer name, phone number, pizza, size, price |
The cells students fill in are left blank in this preview.
Data requirements for an order
| Field | Kind of data | Rule |
|---|---|---|
| customer_name | Text | Cannot be empty |
| phone | Text | Text, because we never do sums with phone numbers |
| quantity | Whole number | 1 to 10 |
| price | Number with decimals | Never below 0 |
| paid | True or False | False until payment works |
The cells students fill in are left blank in this preview.
Your turn: a wireframe
Make a wireframe of a sign-in screen for the school app. Use only boxes and text, no colours. It needs a title, an email box, a password box, a Sign in button and a link that says "Forgot password?". Change the HTML on the left and look at the preview. Keep it simple.
<h1>School app</h1>
<!-- Add the email box, the password box, the button and the link here -->
Make a free account to save your work, or press Start lab to work through the whole lesson.
An algorithm for the delivery fee
flowchart TD
a([Start]) --> b[Add up the food]
b --> c{Food total is 20 or more?}
c -->|yes| d[Fee is 0]
c -->|no| e[Fee is 3]
d --> f[Show the bill]
e --> f
AI code can look right and be wrong
A generative AI can write a section of code in seconds. You type a prompt. It gives code back.
The code looks neat and correct, but it can be wrong. The AI does not know your requirements unless you tell it. You check every line you use.
Run the AI code: it looks fine
def delivery_fee(food_total):
if food_total > 20:
return 0
return 3
print(delivery_fee(10))
print(delivery_fee(30))
print(delivery_fee(20))
# Requirement: free delivery at 20 or more.
# Look at the last line of output. Is it right?
Make a free account to save your work and track your progress.
How to review AI code
Important
- Write the requirements first. 2. Ask the AI for one small function. 3. Read every line. 4. Test the limits: the smallest, the biggest and the exact limit. 5. Fix it, or ask again with a better prompt.
Your turn: fix the AI code
An AI tool wrote the three functions in the starter. Each one breaks a requirement. Read the comment above each function, then fix the code. The hidden tests check the exact limits. Press Run Tests when you are ready.
# An AI tool wrote these three functions for the pizza app.
# They run, but each one breaks a requirement. Fix them.
def delivery_fee(food_total):
# Requirement: delivery costs 3. It is free when the food total is 20 or more.
if food_total > 20:
return 0
return 3
def valid_quantity(quantity):
# Requirement: a customer may order from 1 to 10 of the same pizza.
return 1 < quantity < 10
def display_name(name):
# Requirement: show the name with only the first letter in capitals.
# For "aisha" give back "Aisha".
return name.upper()
Make a free account to save your work, or press Start lab to work through the whole lesson.
Good habit or bad habit?
Have a go
Good habit or bad habit?
6 questionsKeep private data out of prompts
Warning
Never type a real customer name, address or password into an AI tool. Use made-up data. Check your college rules too, and the licence of any code you copy.
Exit quiz
Have a go