Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Maintainability

Maintainable code is code that can be read, understood, and fixed by other developers. There are a few best-practice techniques to help write maintainable code, including:

Comments

Comments

  • Comments should be used throughout the code to:
    • Explain complex processes.
    • Clarify the purpose of algorithms.
    • Clarify the purpose of a subroutine, as well as its parameters and return type and value.
Indentation

Indentation

  • It is good practice to keep indentation of code consistent throughout the code.
  • When a new block of code opens, it should be indented to the right.
  • When a block of code closes, it should return to the left.
  • This makes code easier to read by visualising the scopes involved.
Identifier names

Identifier names

  • Identifier names should be clear about their purpose. For example, which of the following two examples makes more sense:
    • newBalance = oldBalance * INTEREST_RATE;
    • a = b * c;
Code structure

Code structure

  • Code should be well structured through the use of subroutines.
  • This allows people to identify a single subroutine that they need to reuse or work on.
Parameters vs global variables

Parameters vs global variables

  • It is good practice to pass data around the program using parameter passing rather than using global variables.
  • This is because passing parameters prevents other subroutines from unexpectedly changing the value of the variables.
Jump to other topics
1

Problem Solving

2

Programming

3

Data

4

Computers

5

Communication & The Internet

6

The Bigger Picture

Practice questions on Maintainability

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
Answer all questions on Maintainability

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium