CIE AS & A Level Computer Science, section 12.3 (Program testing and maintenance)
Why maintenance is needed
Software must be maintained after it is in use: faults appear, the environment changes (new hardware or laws), and users want new features.
Types of maintenance
| Type | Purpose | Example |
|---|---|---|
| Corrective | fix errors found after the program is in use | correcting a wrong total in a report |
| Adaptive | adapt the program to a changed environment or new requirement | updating the program for a new tax rate, or for a new operating system |
| Perfective | improve the program: faster, easier to use, or with extra features | adding a search box, or making a process quicker |
Analysing and amending a program
To make changes to an existing program:
- Read and understand the existing code and any documentation.
- Identify which parts need to change.
- Make the change, keeping to the same style.
- Test that the new feature works and that nothing else has stopped working (regression testing).
- Update the documentation.
Example: a program calculates a bill with a fixed tax rate 0.2. To amend it, replace the constant with a named constant TaxRate, so future changes only need one edit.
TAX_RATE = 0.2 # adaptive change: one place to edit
def total(price):
return price * (1 + TAX_RATE)
print(total(50)) # 60.0
Making programs easier to maintain
Use meaningful names, comments, modules with clear interfaces, constants and good documentation.
Common mistake: mixing up adaptive and perfective. Adaptive responds to a change in the environment or requirements; perfective improves the program that already works. Also, maintenance includes testing the changes, not just editing the code.
Exam tip: for each type of maintenance, give the purpose and an example linked to the scenario. When amending a program, mention testing the change and updating the documentation.
Check yourself
What is corrective maintenance?
Fixing errors found after the program has been put into use.
A program is changed to use a new tax rate. Which type of maintenance is this?
Adaptive maintenance.
Why should code be tested again after an amendment?
To check the change works and has not caused faults elsewhere in the program.