Which one is decomposition?
Which of the following is an example of decomposition?
A A route map that shows the stations and the connections between them, but not the real distances
B Splitting a payroll program into separate modules to input hours worked, calculate pay and print payslips
C Choosing the identifier name HoursWorked instead of H
D Checking a program line by line, by hand, with a trace table
[1]
- 1
Recall what decomposition does. Decomposition breaks a problem down into smaller sub-problems, each of which can be solved separately and can become a program module.
- 2
Check each option. A leaves out unnecessary detail, so it is abstraction. C is choosing a meaningful identifier name. D is a dry run, which is a testing method. B splits one large problem (payroll) into three smaller tasks, each a module. Answer B (1).
Answer
B
Examiner tip
Examiner tip: a quick test is to ask 'has one big thing been split into several smaller things?' (decomposition) or 'has detail been left out?' (abstraction).
Common mistake: choosing A because a map 'breaks the city down into stations'. The map removes detail that a passenger does not need; it does not split a problem into sub-problems.