Question 1
2 marksA programmer is writing a large program for a school's online quiz.
Give two benefits of using sub programs when writing this program.
Model answer
A sub program, such as one that checks an answer, can be called every time it is needed instead of writing the same code again. Each sub program can also be tested on its own, which makes errors easier to find.
Explanation
Sub programs produce structured code: the program is split into named parts that each do one job. This avoids repeated code, lets each part be tested and fixed separately, lets a team share the work and means a change only has to be made in one place. Vague answers such as 'it is easier' or 'it saves time' do not score unless they say what is easier and why.
Mark scheme
-
1 mark
code can be reused / called many times without being written out again
1 mark for each different benefit, max 2. Accept 'less duplicated code / the program is shorter' as this benefit. Do not accept 'saves time' or 'easier' on their own.
-
1 mark
each sub program can be tested / debugged on its own
-
1 mark
easier to maintain / update: a change only needs to be made once, in the sub program
-
1 mark
different programmers can work on different sub programs at the same time
-
1 mark
the program is easier to read / understand because it is split into named, manageable parts
Accept 'gives the program a clear structure'.
-
1 mark
sub programs can be saved in a library and used in other programs