Maintaining Programs
Why is it important to create a maintainable program?
- Improve program quality:
- A maintainable program is easier to understand and modify, which leads to fewer bugs and better program quality
- Reduce development time and costs:
- A maintainable program requires less time and effort to modify, which reduces development time and costs
- Enables collaboration:
- A maintainable program makes it easier for multiple developers to work together on the same project, as it's easier to understand and modify
- Increase program lifespan:
- A maintainable program is more likely to be updated and maintained over time, which increases its lifespan and usefulness
- Adapt to changing requirements:
- A maintainable program is easier to modify to adapt to changing requirements or new features
How do you create a well maintained program?
- Use meaningful identifiers:
- Identifiers are names given to variables, constants, arrays, procedures and functions
- Use descriptive and meaningful identifiers to make your code easier to understand and maintain
- Avoid using single letters or abbreviations that may not be clear to others
- Use the commenting feature provided by the programming language:
- Comments are used to add descriptions to the code that help readers understand what the code is doing
- Use comments to explain the purpose of variables, constants, procedures, functions and any other parts of the code that may not be immediately clear
- Use comments to document any assumptions or limitations of the code
- Use procedures and functions:
- Procedures and functions are reusable blocks of code that perform specific tasks
- Using procedures and functions allows you to modularise your code and make it easier to understand, debug and maintain
- Procedures and functions should have descriptive names that clearly indicate what they do
- Relevant and appropriate commenting of syntax:
- Commenting of syntax is used to explain the purpose of individual lines or blocks of code within the program
- Use commenting of syntax to describe complex algorithms, or to provide additional information on the purpose or behaviour of code