Menu

Computational Thinking

Benefits of Decomposition

Decomposition breaks a problem into smaller sub-problems, and the benefits come from those parts: one huge problem is hard to hold in your head, while several small ones are manageable.

Each sub-problem is simpler to understand, write and test. You concentrate on one small job at a time: in a cinema booking program, getting the seat prices right is something you can finish and check before you touch anything else.

Different people can work on different sub-problems at the same time. One programmer could build the seat picker while another builds the card payment, so the project is finished sooner.

A finished sub-problem can be reused in another program. The payment section written for the cinema could go into a swimming pool booking system with little change, so nobody solves that problem a second time.

Decomposition also makes it clearer what the whole solution has to cover, because the sub-problems are a checklist of everything the finished program must do. And when something goes wrong, faults are easier to find: if a ticket prints the wrong price but the seat map looks right, you test the pricing part on its own instead of searching the whole program.

BenefitWhy it helpsIn a cinema booking program
Simpler to understand, write and testYou focus on one small job at a timeThe pricing part is tested before payment is added
Work in parallelSeveral people make progress at onceOne builds the seat picker, another builds payment
ReuseA solved part can be dropped into another programThe payment section suits a pool booking system too
See the whole problemThe sub-problems list everything the solution must doYou can check no job has been forgotten
Find faultsEach part can be checked separatelyA wrong ticket price points to the pricing part only

A charity fair as one large problem split into booking stalls, selling tickets, arranging first aid and advertising, with the three benefits: easier to analyse, work can be shared and easier to test and maintain.

Practise this