Computational Thinking · Cambridge syllabus 7.1, 7.2, 7.3 · Lesson 1 of 4
Decomposition
Decomposition splits a complex problem into manageable sub-problems with clear responsibilities. Identify what each part receives and produces so the parts can be developed and tested separately.
By the end, you can
- Understand decomposition.
- Break a complex problem into smaller sub-problems.
- Explain how decomposition makes problems easier to solve.
- Understand that every computer system is made up of sub-systems, which are made up of further sub-systems.
- Draw a structure diagram to show how a problem is decomposed.
Breaking down problems
Decomposition is breaking a problem into smaller sub-problems, and breaking those down again, until each piece is small enough to solve on its own.
It is done because a large problem cannot be held in mind at once. Write a school management system is not a thing anyone can start; store a pupil record, produce one class register, calculate one set of averages are all things that can be started immediately.
The practical method is to ask what the system has to do, list those tasks, and then take each task and ask the same question again. A cash machine, for example, breaks into read the card, authenticate the user, show the menu, check the balance, dispense the cash, print the receipt, update the account — and authenticate the user breaks further into read the PIN, compare it with the stored value, count failed attempts, retain the card after three failures.
The benefits are worth stating precisely. Each piece is simple enough to be understood and tested on its own; different people can work on different pieces at the same time; a piece that solves a common task can be reused elsewhere; and when something goes wrong, the fault is in one identifiable piece rather than somewhere in the whole.
It maps directly onto how a program is written: each sub-problem becomes a procedure or function, and the main program calls them in order. Decomposition is not a preliminary exercise — it is the structure of the finished code.
Every computer system is made up of sub-systems, which are made up of further sub-systems. A cash machine is a sub-system of a bank’s system; the cash machine itself is made of sub-systems for the card, the user, the cash and the account. Each part of a system can be described by its inputs, its processes, its outputs and the data it stores.
A structure diagram shows a decomposition as a tree. The whole system is a box at the top; the boxes on the level below are its sub-systems, joined to it by lines; and each of those is broken down again on the next level, read from left to right. For the cash machine, the top box is the cash machine, the next level is card, user, menu, cash and account, and under user are read PIN, check PIN and count failed attempts. It shows what the parts are and how they fit together, not the order of every step.
Worth remembering
- Break a problem into sub-problems, and those into smaller ones still.
- Each piece can be understood, written and tested independently, and reused.
- Every system is made of sub-systems, which are made of further sub-systems.
- A structure diagram shows the decomposition as a tree of boxes, top down.
Worked example
A quiz system can be split into loading questions, accepting answers, checking answers and displaying a score.
Practice
Warm-up · not marked
Check your understanding
Answer in your own words, then compare with the worked answer. Nothing here is saved or scored.
Worked answer
Separate input and validation, storage of marks, total/count calculation, and formatted output.
Check your method, units and explanation against it.
Marked practice
Set 1 of 5 · easiest first · Checked as you go, with the worked answer. Sign in or create a free account to save your progress.