Program Maintainability (OCR GCSE Computer Science)

Revision Note

James Woodhouse

Written by: James Woodhouse

Reviewed by: Lucy Kirkham

Program Maintainability

What is program maintainability?

  • Maintainability is used to ensure programmers can easily understand what a program is doing months or years after having first written it

  • Maintainability is also used when programming as part of a large team, so each programmer working on the team understands what each section is doing

How are programs maintained?

  • Commenting of code: to explain the purpose of the code in a particular section

  • White space: to make each section clear and easy to see

  • Indentation: to show each instance of selection and iteration and to make it clear which code belongs to which clause in the program

  • Sensible variable names: so that the name explains what that variable or data structure does and to prevent confusion later in the development process

  • Use of sub-programs: functions or procedures split up programs into reusable sections of code which can remove the need for duplicating code and also increase the overall structure of the code

An example of maintainability

  • The first image below shows the code for a bubble sort algorithm written in Python

  • The code does not include any of the maintainability features mentioned in this section

Image of a bubble sort in python without any maintainability features
  • The second image, below, is the same program however, it clearly shows the use of

    • comments

    • meaningful variable names

    • white space

    • indentation

  • By including each of these, the code immediately becomes easier to

    • read

    • understand

    • debug

    • improve

Image of a bubble sort in python with 4 maintainability features

Worked Example

The area of a circle is calculated using the formula straight pi space straight x space r squared, where straight pi is equal to 3.142 and r is the radius.

George has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30, and output the area of the circle.

radius = int(0)
area = float(0.0)
radius = int(input("Enter radius: "))
if radius < 1 or radius > 30:
print("That radius is invalid")
else
area = 3.142 x(radius2)
print(area)

Explain, using examples from the program, two ways Finn can improve the maintainability of the program. [6]

How to answer this question

  • To score full marks on this type of question you will be awarded

    • 1 mark for identifying a maintainability feature 

    • 1 mark for explaining how it aids maintainability

    • 1 mark for applying it to the context in the question

Answers: Maximum of 3 marks per method

  • Comments/annotation

    • To explain the key functions/sections

    • E.g. any relevant example, such as line 4 checks the input is valid

  • Indentation

    • To show where constructs/sections start and finish

    • E.g. indenting within IF statement

  • White space

    • So the code appears easier to read and understand

    • E.g. leaving a line break after the radius input 

Last updated:

You've read 0 of your 5 free revision notes this week

Sign up now. It’s free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.