GCSE · Computer Science · AQA · Spec 8525

Advantages of subroutines

Your quiz game's menu says 'Qiut'. How many places must you fix? If the answer is 'just one', you've already met the big idea of this lesson.

Computer Science · Subroutines

Which advantage is it?

Pick a situation, then put it under the advantage it shows. Each placement comes with the reason, right or wrong.

Still to sort

Code reuse (0)

Written once, called as many times as needed, so no repeated lines.

Where the line is: Reuse means not writing the same lines again. If the story is about changing code later, that's Maintenance.

Decomposition (0)

A big problem broken into smaller sub-problems, one subroutine each.

Where the line is: Decomposition is breaking the problem down to design it. Sharing those parts out between people is Teamwork.

Testing and debugging (0)

One part checked on its own, so an error has fewer places to hide.

Where the line is: This is about finding errors. A correction then reaching every call is Maintenance.

Maintenance (0)

A correction or improvement made once takes effect at every call.

Where the line is: Maintenance is a change made later. Not having to type the lines in the first place is Code reuse.

Readability (0)

The main program reads like a list of clearly named steps.

Where the line is: Readability is about a person reading the program. Breaking the problem down to plan it is Decomposition.

Teamwork and libraries (0)

Programmers share out the work, or a tested subroutine goes on to other programs.

Where the line is: Calling a subroutine many times in ONE program is Code reuse. Using it in OTHER programs, from a library, belongs here.

8 of 8 still to sort.

Six advantages, eight situations. Some advantages get two situations and some get one, so don't expect the columns to fill evenly.

Watch out: "It makes the program easier" doesn't name an advantage. Say WHICH one, and what it makes easier.

Same program, two ways

Menu lines copied out three timesvsMenu in a subroutine, called three times

A quiz program shows its three-line menu (1 Play, 2 Rules, 3 Quit) in three different places.

Focus

Where the menu's code lives

Menu lines copied out three times

Three copies of the same three OUTPUT lines, pasted wherever the menu appears

Menu in a subroutine, called three times

One copy, inside a subroutine called show_menu. Each place that needs the menu just calls show_menu()

The insight

Written once, called as often as you like: that's code reuse, and it's where the other advantages start.

Length of the main program

Menu lines copied out three times

9 lines just to show the menu three times

Menu in a subroutine, called three times

3 lines: one call each time

Reading the main program

Menu lines copied out three times

The steps of the quiz are buried among menu details

Menu in a subroutine, called three times

It reads as named steps: show_menu(), get_choice(), ask_question() …

Checking the menu works

Menu lines copied out three times

Only by running the whole quiz up to each point where a menu appears

Menu in a subroutine, called three times

Call show_menu on its own and check it, before the rest of the quiz is finished

The menu says 'Qiut' instead of 'Quit'

Menu lines copied out three times

Three places to fix. Miss one and the typo survives

Menu in a subroutine, called three times

One line to fix, inside show_menu

Maintenance

?

Reason it through

Why does one fix inside show_menu correct the menu everywhere in the program?

Link 1 of 4

First link · your turn

Where does the code for showing the menu actually live?

2
Locked — reveal the link above first
3
Locked — reveal the link above first
4
Locked — reveal the link above first

Decomposition, teamwork and libraries

Break it down, share it out
Quiz game

View: 1 · The problem. Showing 1 layer: The whole problem

View

Layers

Explore

step through the views →

One big problem: a whole quiz game. Designing it in one go would mean holding every detail in your head at once.

Step through the four views, then tap any box to see what it shows.

Computer Science · Subroutines

Worth it for code used once?

A program ends by printing a receipt. The receipt code is in a subroutine called print_receipt, and it is called exactly once, at the very end.

Why would a programmer bother making print_receipt a subroutine? Which is closest to what you think right now?
How sure are you?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Write a task once, in one named place, and a whole list of problems goes away.

What you need to know

  • A subroutine is a named, self-contained block of code that performs one task. It runs only when another part of the program calls it.
  • Almost every advantage comes from one fact: the task is written once, in one named place.
  • The six advantages are code reuse, decomposition, testing and debugging, maintenance, readability, and teamwork and libraries.
  • The benefits are to how a program is written, tested and maintained, not to how fast it runs.

The big picture

A subroutine is a named, self-contained block of code that does one task and runs when it is called. Because each task is written once, in one place, subroutines bring six advantages: code reuse, decomposition, testing and debugging, maintenance, readability, and teamwork and libraries. They make a program easier to write, test and maintain, not faster to run, and they help even when a subroutine is called only once.

Key points

1Code reuse: write the lines once and call them as many times as needed. The program is shorter and mistakes aren't copied into several places.
2Decomposition: a large problem becomes smaller sub-problems, each solved by its own subroutine and simpler to design, write and understand.
3Testing and debugging: each subroutine can be tested on its own before joining the rest, and an error is easier to find because it's isolated to a small section.
4Maintenance: a correction or improvement is made once, inside the subroutine, and takes effect everywhere it is called.
5Readability: well-named calls make the main program shorter and let the reader see the overall steps without the detail of each one.
6Teamwork and libraries: different programmers can write and test separate subroutines at the same time, and a well-tested subroutine can be used in other programs, for example from a library.

Worked example

Problem

A cinema-booking program checks that a seat number typed in is valid, and it does this in five different places. Explain two advantages of putting the seat check in a subroutine.

⚠ Watch out

Saying subroutines make a program "easier" or "faster". "Easier" doesn't name an advantage: say which one, and what it makes easier. "Faster" isn't the reason at all. The advantages are about writing, testing and maintaining code, and they apply even to a subroutine that is called only once.

🧠

Memory hook

Really Determined Testers Maintain Readable Libraries: Reuse, Decomposition, Testing, Maintenance, Readability, Libraries (and teamwork). Underneath all six: one task, written once, in one named place.

✓

Check yourself

Cover the page. Name all six advantages of subroutines and give a one-line reason for each. Then explain why a subroutine that is called only once can still be worth writing.

Flashcards

(11)
What is a subroutine?
A named, self-contained block of code that performs one task. It runs only when another part of the program calls it.
The one fact behind almost every advantage of subroutines
The task's code is written once, in one named, self-contained place.
Code reuse
Lines written once in a subroutine and called as many times as needed. The program is shorter and mistakes aren't copied into several places.
Decomposition
Breaking a large problem into smaller sub-problems, each solved by its own subroutine, so each part is simpler to design, write and understand.
Testing and debugging
Each subroutine can be tested on its own before it joins the rest. An error is easier to find because it's isolated to a small section.
Maintenance
A correction or improvement is made once, inside the subroutine, and takes effect everywhere the subroutine is called.
Readability
Well-named subroutine calls make the main program shorter and easier to follow: you see the steps without the detail of each one.
Teamwork
Different programmers can write and test separate subroutines at the same time.
Libraries
A well-tested subroutine can be stored in a library and used in other programs, not just called again inside the one it was written for.
Do subroutines make a program run faster?
That isn't why they're used. Their advantages are about how a program is written, tested and maintained.
Is a subroutine worth writing if it's called only once?
Yes. It still breaks the problem into a smaller part, makes the main program easier to read, and can be tested on its own.

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 posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

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 29 September 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.