Maintainability is the ease with which a program can be understood, modified and extended over time. In the Cambridge IGCSE 0478 syllabus a maintainable program is required for:
11001₂.11001₂ = 19₁₆.0001 1001 → 1110 0110, add 1 → 1110 0111₂.65₁₀ = 0100 0001₂.int vs float) and write efficient, maintainable code.https://www.example.com/index.html).| Element | Recommended Style | Example |
|---|---|---|
| Variables | snake_case (Python) / lowerCamelCase (Java) / PascalCase (pseudocode) | total_score, studentName, ScoreTotal |
| Constants | UPPER_SNAKE_CASE | MAX_ATTEMPTS, TAX_RATE |
| Functions / Procedures | snake_case (Python) / lowerCamelCase (Java) / PascalCase (pseudocode) | calculate_average, computeTotal, CalculateTotal |
| Classes (if used) | UpperCamelCase | StudentRecord |
snake_case for variables, explain why it improves readability for a future maintainer (e.g., it separates words clearly, matches the language’s standard library, and avoids ambiguity with class names).
# Author: Jane Doe
# Date: 30‑12‑2025
# Purpose: Calculate and print a sales receipt
# Version: 1.0
# or //).
def calculate_total(price, quantity):
"""
Returns the total cost for a line item.
Parameters:
price – unit price (float)
quantity – number of units (int)
Returns:
float – price × quantity
"""
Each function should perform a single, well‑defined task. This makes the code easier to test, reuse and modify.
FUNCTION CalculateTotal(price, quantity)
RETURN price * quantity
END FUNCTION
PROCEDURE PrintReceipt(items)
total ← 0
FOR EACH item IN items
lineTotal ← CalculateTotal(item.price, item.qty)
total ← total + lineTotal
// display line (item name, qty, lineTotal)
END FOR
// display total
END PROCEDURE
Validation checks that input data meet required criteria before they are processed. Verification checks that the program’s output matches the expected result.
DD/MM/YYYY.
READ score
IF score < 0 OR score > 100 THEN
DISPLAY "Error: score must be between 0 and 100"
STOP
END IF
# Test CalculateTotal INPUT price = 9.99, quantity = 3 EXPECTED output = 29.97 ACTUAL = CalculateTotal(price, quantity) ASSERT ACTUAL = EXPECTED
Test each function in isolation with known inputs and expected outputs.
# Unit test for CalculateAverage INPUT scores = [80, 90, 70] EXPECTED = 80.0 ACTUAL = CalculateAverage(scores) ASSERT ACTUAL = EXPECTED
Combine functions and verify that data flow works correctly.
# Integration test for PrintReceipt
CALL PrintReceipt([ {price:5, qty:2}, {price:7.5, qty:1} ])
# Verify that the displayed total equals 17.5
A trace table records the values of variables after each step of execution.
| Step | price | quantity | total |
|---|---|---|---|
| Initial | ‑ | ‑ | 0 |
| CALL CalculateTotal(5,2) | 5 | 2 | 10 |
| CALL CalculateTotal(7.5,1) | 7.5 | 1 | 17.5 |
Version control is not examined but helps students experience real‑world software development.
git init git add receipt.py git commit -m "Add CalculateTotal function" git branch feature/validation
“Store the scores of up to 30 students. Each score must be between 0 and 100. After all scores are entered, display the highest, lowest and average score.”
(Main) → ReadScores → AnalyseScores → DisplayResults
(Insert a simple flowchart showing a loop for reading scores, a decision diamond for validation, then processing steps.)
# Author: Jane Doe
# Date: 30‑12‑2025
# Purpose: Record student scores and report statistics
# Version: 1.0
CONSTANT MAX_STUDENTS ← 30
CONSTANT MIN_SCORE ← 0
CONSTANT MAX_SCORE ← 100
PROCEDURE Main()
scores ← [] # empty list
CALL ReadScores(scores)
CALL AnalyseScores(scores)
END PROCEDURE
PROCEDURE ReadScores(REF scores)
WHILE LENGTH(scores) < MAX_STUDENTS
DISPLAY "Enter score (or -1 to finish): "
READ inputScore
IF inputScore = -1 THEN
EXIT WHILE
END IF
IF inputScore < MIN_SCORE OR inputScore > MAX_SCORE THEN
DISPLAY "Error: score must be 0‑100"
CONTINUE WHILE # ask for another value
END IF
APPEND inputScore TO scores
END WHILE
END PROCEDURE
PROCEDURE AnalyseScores(scores)
IF LENGTH(scores) = 0 THEN
DISPLAY "No scores entered."
STOP
END IF
highest ← scores[1]
lowest ← scores[1]
total ← 0
FOR EACH s IN scores
IF s > highest THEN highest ← s END IF
IF s < lowest THEN lowest ← s END IF
total ← total + s
END FOR
average ← total / LENGTH(scores)
CALL DisplayResults(highest, lowest, average)
END PROCEDURE
PROCEDURE DisplayResults(high, low, avg)
DISPLAY "Highest score : ", high
DISPLAY "Lowest score : ", low
DISPLAY "Average score : ", avg
END PROCEDURE
CALL Main()
AnalyseScores| Iteration | s | highest | lowest | total |
|---|---|---|---|---|
| 0 (initial) | ‑ | 90 | 90 | 0 |
| 1 | 90 | 90 | 90 | 90 |
| 2 | 70 | 90 | 70 | 160 |
| 3 | 80 | 90 | 70 | 240 |
ReadScores guarantees each score is 0‑100.AnalyseScores you could add a unit test:
INPUT scores = [90, 70, 80]
EXPECT highest = 90, lowest = 70, average = 80
| Checklist Item | Yes / No |
|---|---|
| Consistent 4‑space indentation throughout the file | |
| All identifiers follow the chosen naming convention | |
| Header comment with author, date, purpose and version | |
| Each function/procedure performs a single, well‑defined task | |
| Every function/procedure has a doc‑string or comment describing parameters and return values | |
| Input validation is present for all user‑supplied data | |
| Unit tests exist for all non‑trivial functions | |
| All “magic numbers” are replaced by named constants | |
| Design choices are evaluated and justified (AO3) | |
| Optional: version‑control commits are frequent with clear messages |
Creating a maintainable program for the IGCSE requires you to:
Mastering these practices will enable you to produce programs that are easy to understand, modify and extend – a key expectation of the Cambridge IGCSE 0478 syllabus and a valuable skill for any future computing work.
Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.