1. Structuring programmes

Decomposition breaks complex problems down into self-contained sub-problems, which are organized into structured subroutines. Functions and procedures communicate cleanly using parameters and return values, creating reliable software that is easy to build, test, and understand.

Why Modular? The Car Analogy
MODULAR ARCHITECTURE Tap to read ▾

Imagine if car manufacturers forged an entire vehicle as a single, solid lump of welded metal. If a headlight burned out or a tyre popped, you would have to scrap the whole vehicle! Instead, cars are assembled from pre-tested, interchangeable parts: braking callipers, alternator, and engine blocks. Crucially, a well-engineered modular component like a wheel, battery, or engine can also be reused in another car model without redesigning it from scratch. In software, writing everything in one giant monolithic script is just as dangerous. Programmers use Decomposition to break complex systems down into independent, reusable Subroutines that can be shared across programs.

1. Monolith (Raw Mess)

500 lines in one huge file. If line 10 crashes, the whole system dies. Impossible to test in pieces or share across a team.

2. Subroutines (Modular Parts)

Independent, single-purpose functions & procedures: check_abs(), calc_pressure(), apply_brakes(). Reusable in other vehicles!

3. Structure Chart (Assembled Blueprint)

A tree blueprint showing exactly who calls whom, with clean parameters passed down ↓ and return values passed up ↑.

INTERACTIVE CHALLENGE 1

Challenge 1: Assemble the Structure Chart

You are designing embedded software for a cash machine (ATM). It reads the customer card and PIN, checks account balance, dispenses cash by checking daily limits and calculating banknote breakdown, and then ejects the card with a receipt.

Instructions: Click a block in the pool to select it, then click an empty slot in the chart (or drag & drop) to place it. Beware of irrelevant distractor tasks!
Root Program Level 1 Sub-problems Level 2 Subroutines
Candidate Blocks Pool (Click to select & place):
ATM Controller
INTERACTIVE CHALLENGE 2

Challenge 2: Data Flow, Parameters & Return Value Wiring

Inputs ↓ (Parameters) • Outputs ↑ (Returns) • Internal 🔒 (Local Scope)

Subroutines exchange data with their calling module across boundaries. Select candidate variables from the pool and assign them into their correct role: Parameters (passed down ↓ ○), Return Values (passed up ↑ ○), or Local Variables (kept internal). The structure chart couple diagram updates live and checks automatically once all variables are assigned.

INTERACTIVE CHALLENGE 3

Challenge 3: "Should This Code Block Be a Subroutine?"

Inspect the monolithic script below. Look for copy-pasted validation loops and self-contained calculations. Decide whether to extract each block into an independent subroutine or keep it in the Main Module.

Cinema Booking Click blocks to inspect
Architecture Tip: Repeated blocks or self-contained formulas should be extracted into subroutines. Top-level program flow controls belong in the Main Module.
Evaluate Candidate Block
Score: 0 / 6 Correct
Block 1: Age Validation


              
Should this block be extracted into an independent subroutine?

Architecture Comparison: Monolith vs Modular Chart