GCSE · Computer Science · AQA · Spec 8525
Structured approach to programming
Something's broken. One giant block of code doing everything, or a handful of small, named jobs: which would you rather fix?
Computer Science · Structure
One program, broken into small jobs
A structure chart for a program that marks a quiz. Tap each box to see its one task and its interface. On the lines, ↓ is a value handed in and ↑ is a value sent back.
Tap any part of the diagram to see what it does.
Computer Science · Subroutines
Watch the program leave, then come back
calculate_percentage from the chart, now as real code. It's written at the top. Watch when it actually runs.
Predict first: when you reach line 6, which line do you think runs next?
1 def calculate_percentage(score, total):2 percentage = score / total * 1003 return percentage4 # main program5 mark = 156 result = calculate_percentage(mark, 20)7 print(result)
Variables
Output
Step 1: The def line tells the program that calculate_percentage exists. The indented lines under it are skipped for now. None of that code has run.
Keep your eye on the highlighted line. It jumps up to the subroutine, then drops back into the main program.
Computer Science · Why bother?
Which advantage is this?
A team is building the quiz marker. Each moment below shows one advantage of the structured approach. Put each one under the advantage it shows.
Still to sort
Easier to read and understand (0)
The code is split into small, manageable sections.
Easier to test (0)
Each subroutine carries out one task, so errors are easier to find and fix.
Where the line is: Testing is about FINDING and fixing a fault. Maintenance is about making a change later without breaking the rest.
Easier to maintain (0)
A change is made and tested in one place without affecting the rest of the program.
Where the line is: If the program is being changed on purpose, not hunted for a bug, it's maintenance.
Faster development (0)
Several programmers can work on different subroutines at the same time.
Where the line is: Faster development is about PEOPLE working in parallel, not about one subroutine being used again.
Reuse (0)
A subroutine can be called many times, so the same code isn't written out again.
Where the line is: Reuse is about CALLING the same subroutine again, not about sharing the work out.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Split one big job into small named jobs, plan them on a chart, and call each one when you need it.
What you need to know
- Big program? Break it into smaller subroutines, each designed to do one specific task.
- Small single-task pieces are easier to solve on their own, so a growing program stays manageable.
- A subroutine is a named sequence of instructions that performs a specific task.
- It's out-of-line code: often written at the top, yet it runs only when the main program calls it.
Have a goPriya writes a perfect subroutine called make_toast at the very top of her program. Her main program never calls it. How many slices get toasted?
None. The make_toast code never runs.
Being written at the top doesn't make it run. Out-of-line code waits for a call, and here nobody ever makes one, however good the subroutine is.
- Plan before you code: a structure chart puts the main program in the top box, its subroutines beneath.
- Each interface sets how data gets in and out: a meaningful identifier, parameters passed in, a return value passed back.
Have a gofind_max(a, b) hands back whichever of its two numbers is bigger. Which part of its interface are a and b, and which part is the bigger number?
a and b are the parameters; the bigger number is the return value.
The tempting slip is to call a and b the return value. They go IN through the brackets; only the result comes back OUT.
- Structured code steers the flow with sequence, selection (if, elif, else) and iteration (while, for), not goto.
- Overuse goto and the code turns messy and hard to follow. That tangle is called spaghetti code.
- One entry, one exit: a while loop should stop because its condition turns false, not because a break forces it.
Have a goA game loop runs while lives > 0, and you lose one life each time round. There's no break anywhere. So what actually ends the game?
The condition turns false when lives reaches 0.
No break needed. In structured code a loop's one exit is its condition becoming false, which is exactly what happens here.
- The payoff: easier to read, test and maintain, faster to develop, and less repeated code.
The big picture
The structured approach breaks a program into small subroutines that each do one specific task. You plan them on a structure chart, give each one a clear interface (identifier, parameters, return value), and they run only when the main program calls them. Structured code steers the flow with sequence, selection and iteration instead of goto, and has one entry point and one exit point. The payoff: programs that are easier to read, test and maintain, faster to develop, and less full of repeated code.
Key points
Worked example
Problem
This loop keeps asking for a password until the right one is typed: while True: guess = input("Password: ") if guess == "open123": break Explain why the loop is not properly structured, then rewrite it so that it is.
⚠ Watch out
Thinking a program runs from top to bottom, so the subroutine written at the top must run first. Feels obvious. It's wrong: a subroutine is out-of-line code that runs only when the main program calls it, and then control comes back to the line that made the call.
Memory hook
Plan it like a family tree, run it like a phone call. The chart shows who sits under whom; when the program runs, main rings a subroutine, hands over the details, waits, and gets an answer back before carrying on.
Check yourself
Cover the page. Name the three parts of a subroutine's interface and say which one carries a value back. Then say why while True with a break inside is not properly structured.
Flashcards
(14)What is the structured approach to programming?
What is a subroutine?
What does 'out of line' mean for a subroutine?
A subroutine is written at the top of a program. Does it run first?
On a structure chart, what does the top box show? What do the boxes beneath it show?
When is a structure chart drawn?
What does a subroutine's interface determine?
Interface: what is the identifier?
Interface: what are the parameters?
Interface: what is the return value?
Which three structures control the flow in structured programming?
What is spaghetti code?
How many entry and exit points does a properly structured program have?
Five advantages of the structured approach?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.