Programming · Higher
Robust & Maintainable Programs
Good programs are not only correct – they resist bad input and are readable for future changes.
Defensive design
• **Validation** – check input is sensible
• **Authentication** – confirm user identity
• Anticipate misuse and edge cases
• Clear error messages
Maintainability
• Meaningful identifiers
• Comments and indentation
• **Subroutines** / functions – reusable blocks
• Avoid unnecessary duplication
Practice questions
1. Why use subroutines?
2. Give two features of maintainable code.