Menu

Abstraction and Decomposition

Decomposition

Decomposition is a computational thinking technique: you take a large problem or system and break it into smaller sub-problems, each of which is far easier to understand and solve than the whole. You then solve the parts and build them back together into the finished thing.

What can be decomposed

Decomposition is not only about programs. It can be applied to the problem itself (what needs solving), to the solution (how you build it) and to algorithms (the steps that get the job done).

Suppose your year group is running a trip to a science museum. As a single problem it feels far too big to start; decomposed, it becomes transport, cost, permission letters and lunch. In the same way, an algorithm that works out the average score in a class splits into: read in the scores, add them together, divide by how many there are, print the answer.

Break each part down again

One split is rarely enough. Keep breaking each sub-problem down until every task is small enough to design, write and test in one go. Under transport you could have "how many coaches are needed", "the cost of hiring one" and "pick-up time". A task you can hold in your head is the point to stop.

Solve the parts, then combine them

Each sub-problem is solved and checked separately, and the finished parts are then combined to produce the overall solution. Because the parts were planned to fit together, a fault in one can be found and corrected without unpicking everything else. The breakdown can be shown as a structure diagram.

Structure diagram of a science museum trip split into transport, cost, permission letters and lunch, with transport split again into how many coaches are needed, cost of hiring one and pick-up time.

Practise this