Why decomposition helps: testing each part separately
Each sub-problem is tested on its own before being joined to the rest, so an error is traced to the part that causes it and only that part needs fixing, not the whole program.
Understanding Why decomposition helps: testing each part separately in IGCSE Computer Science Paper 2
What it does: The test of CalcTotal fails because it adds instead of multiplying, so the error is traced to this function and not the whole program. Only the faulty line in CalcTotal is corrected. The other subroutines were already tested and stay unchanged. Testing parts separately means a failing test points to the part that causes the error. Testing one subroutine before joining it to the others catches errors early and keeps them easy to locate. Decomposition does not stop errors being made, it makes them easier to find and fix. Calling a single subroutine with known inputs tests that part on its own, before it is joined to the rest of the program.
Common mistakes: The test expects the wrong answer. 2 * 3 is 6, so a correct Area function would be reported as failing. A test of one subroutine must check against the right expected value (6) so a failure really points to that part. A PROCEDURE must be closed with ENDPROCEDURE, not ENDFUNCTION. Until this part is fixed it cannot be tested on its own, and only this procedure needs correcting.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 94–106) and word search (Modules 94–118).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
test each sub-problem separatelyFill in the Blanks
Spot the Error
Student with a class code? Join your class →