- Why split a program into modules?
Big problems are easier to solve, test and maintain when broken into single-purpose routines.
Imagine one enormous block of code that reads input, validates it, calculates totals, prints reports and saves files — all jumbled together. It is hard to read, hard to test, and a single change risks breaking everything.
Structured (modular) programming solves this by dividing the program into small, named, single-purpose modules. Each module does one job and can be:
- reused — written once, called many times (no copy-paste);
- tested on its own — easier to find and fix faults;
- understood quickly — a main program of meaningful calls reads like a summary;
- shared out — different people can work on different modules at once.
There are two kinds of module in 9618 pseudocode:
| Module | Returns a value? | How you invoke it |
|---|---|---|
| Procedure | No — it does a task | as a statement: CALL Name(...) |
| Function | Yes — a single value | inside an expression: x ← Name(...) |
The rest of these notes builds up both, plus how data is passed in and out.
- Modular programming = many small single-purpose routines.
- Benefits: reuse, easier testing/debugging, readability, teamwork.
- Procedure → does a task, no return value, invoked with CALL.
- Function → returns one value, used inside an expression.