AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Theory of Computation
Decomposition and Composition
- 2 things to know
- Paper 1
Overview
Recall questions on what procedural decomposition is, how a problem is broken down, its benefits and what distinguishes a good decomposition.
What you need to know
Answer each one before you reveal it.
Give three examples of compound data objects built from previously defined types.
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is procedural decomposition?
Model answer
In procedural decomposition a problem is split into sub-problems, each of which accomplishes some identifiable task, and any sub-problem still too large can be split again in the same way. A payroll system, for example, separates into reading employee records, calculating gross pay, deducting tax and printing payslips — and 'deducting tax' may itself break down further into separate bands and allowances.
- 2
Decompose the problem 'produce end-of-year reports for a school' and show the further subdivision.
Model answer
At the top level: read the marks from file; calculate each student's results; sort the students into class order; produce the report documents. Each accomplishes an identifiable task. 'Calculate each student's results' subdivides further into: calculate the mean mark per subject; convert each mark into a grade; work out the overall average. 'Produce the report documents' subdivides into: fill in the heading with the student's details; add one line per subject; add the tutor's comment. The subdivision stops when each remaining task is small enough to write as a single procedure.
- 3
State three benefits of decomposing a problem before writing any code.
Model answer
Each sub-problem is small enough to be understood, written and tested on its own, so mistakes are found in one small piece rather than in a large tangle. Different people can work on different sub-problems at the same time, because each has a defined task. Sub-problems that occur more than once — such as 'convert a mark into a grade' — need only be solved once and can be reused wherever they are needed, and can be improved later in one place.
- 4
How do you tell a good decomposition from a poor one?
Model answer
In a good decomposition each sub-problem accomplishes a single identifiable task that can be named in a few words, and the sub-problems interact through a small, clearly stated set of values passed between them. In a poor one the pieces are named vaguely, several pieces have to be changed together whenever the requirement changes, and each piece needs to know a great deal about the internal workings of the others — which means the problem has been cut in the wrong place.
- 5
What is composition, and how does it relate to decomposition?
Model answer
Composition is building something larger by combining existing parts: combining procedures to form compound procedures, and combining data objects to form compound data. It is the opposite direction of travel from decomposition, which starts with a whole problem and splits it into sub-problems. In practice a solution is decomposed on paper and then composed in code, the small procedures being written first and combined into larger ones.
- 6
Give a worked example of building a compound procedure by composition.
Model answer
Suppose validateMark, convertToGrade and writeToReport already exist. A compound procedure is built by combining them: PROCEDURE processStudent(student) FOR EACH mark IN student.marks IF validateMark(mark) THEN grade ← convertToGrade(mark) writeToReport(student, grade) ENDIF ENDFOR ENDPROCEDURE processStudent is a new procedure made entirely out of existing ones, and it can in turn be combined into processWholeClass. Each level can be used without knowing how the level below works.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Theory of Computation, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.