Make a program maintainable
Use meaningful identifiers, comments and reusable routines so another person can follow and update a program.
Section 8 · Programming
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
Why are comments useful?
What you will learn
- Choose meaningful names for program elements
- Add relevant comments
- Use procedures and functions to keep work organised
Names communicate purpose
Use meaningful identifiers for variables, constants, arrays, procedures and functions. A name such as CalculateAverage is easier to understand than P2.
Consistent names help a reader connect a variable to the requirement it represents. Keep names precise and avoid changing terminology between related sections.
Comments should explain relevant decisions
Use the language's commenting feature for reasons, assumptions or non-obvious steps. A comment that merely repeats the next line adds little.
Reusable procedures and functions reduce duplicated logic. When a rule changes, one well-named routine is easier to update than several copied blocks.
Pause and explain
A 10-line calculation appears in four places. What helps maintainability?
Worked example
Improve the maintainability of a program that uses X, Y and repeated calculations of tax.
Show the worked solution
- Rename X and Y to describe their data.
- Move the repeated tax calculation into a named function.
- Comment the tax rule if the reason or assumption is not obvious.
Answer Use identifiers such as TaxableIncome and TaxAmount, call CalculateTax, and document the rule that determines the rate.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Suggest clearer names for A, B and C when they store a unit price, quantity and total cost.
Give me a hint
Choose identifiers that describe each value.
Compare my reasoning
- A becomes UnitPrice.
- B becomes Quantity.
- C becomes TotalCost.
Use UnitPrice, Quantity and TotalCost.
Look for these in your work
- Each name describes its purpose
- Names remain distinct
A line says Total ← Price * Quantity. Write a useful comment that adds information instead of repeating the line.
Give me a hint
Explain an assumption or rule that is not visible in the expression.
Compare my reasoning
- State what Price includes or how Quantity is interpreted.
- Keep the comment relevant to the calculation.
- Avoid merely saying the line calculates Total.
For example: // Price is the pre-tax price for one item.
Look for these in your work
- Additional context
- Relevant explanation
Two copied price-calculation blocks now use different tax rates by mistake. Describe a maintainable correction.
Give me a hint
Reduce duplicated logic and verify the rule in one place.
Compare my reasoning
- Create one CalculateTotalPrice routine.
- Pass the price and applicable rate explicitly.
- Replace both copied blocks with calls and test both scenarios.
Centralise the calculation in one named routine, pass the needed values, and test each rate case.
Look for these in your work
- Reuse introduced
- Inputs explicit
- Scenarios retested
Common mistakes
- Adding comments that repeat every line verbatim
- Using one-letter names for important data
- Copying the same calculation into multiple places
What can you explain now?
Which change most improves a variable name?
Compare with the explanation
Replace X with a name such as NumberOfAttempts
A meaningful identifier describes the value's purpose.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
How do meaningful identifiers and reusable routines make a program easier to update?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.