Decomposition: breaking a problem down

Computer Science · Key Stage 2 · The School

Too big to start

"Make a game" is not something you can begin. "Draw the player", "move the player left and right", "drop something from the top", "notice when they touch", "keep the score" are five things you can each begin today. DECOMPOSITION is the habit of turning the first sentence into the second list, and it is the single most useful idea in computing.

Why smaller parts are easier

Three reasons. You can finish one and see it work, which tells you the idea is sound. You can test each part on its own, so when something breaks you already know which part to look at. And you can do the parts in any sensible order, or share them out between people. A program written as one enormous piece can only be debugged by reading all of it.

When a part is still too big

A part is small enough when you can say exactly what it does in one sentence, and you can imagine writing it. "Handle the player" fails both tests — handle it how? "Move the player 10 steps right when the right arrow is pressed" passes both. If you cannot start a part, that is not a sign you cannot do it; it is a sign it needs splitting again.

"Make a quiz game" is too big. Split it: (1) store the questions and answers, (2) show one question, (3) get the player's answer, (4) check it, (5) keep the score, (6) show the final score. Each of those you could sit down and write. Is any still too big? Part 1 might split further into 'decide the format' and 'load them from a file'. Stop splitting when every part is one job you can test alone.

The School — all subjects · Knowledge map