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.
500 lines in one huge file. If line 10 crashes, the whole system dies. Impossible to test in pieces or share across a team.
Independent, single-purpose functions & procedures: check_abs(), calc_pressure(), apply_brakes(). Reusable in other vehicles!
A tree blueprint showing exactly who calls whom, with clean parameters passed down ↓ and return values passed up ↑.
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.
Challenge 2: Data Flow, Parameters & Return Value Wiring
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.
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.