SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Cambridge IGCSE 0478 · Topic 8 · 8.5

Writing &
Testing Programs

Types of Error · Test Data · Debugging · Good Programming Practice

CSZoneCambridge IGCSE Computer Science 0478
Types of Program Error

Three Error Types to Know

Syntax error: code doesn't follow the language's rules. Detected at compilation/interpretation — program won't run. e.g. missing ENDIF, misspelling a keyword.
Logic error: program runs without crashing but produces wrong output. The algorithm is incorrect. Hardest to find. e.g. using + instead of *, wrong loop bounds.
Runtime error: program crashes during execution. e.g. division by zero, trying to access an array element outside its bounds.
Test Data Strategies

Normal, Boundary & Erroneous

Test TypeDefinitionExample (age 0–120)
NormalTypical valid input25, 45, 70
BoundaryAt the edges of valid range0, 1, 119, 120
ErroneousInvalid — should be rejected-5, 200, "twenty"
Boundary testing is critical — many bugs occur at the edges (e.g. off-by-one errors in loop conditions)
Good Programming Practice

Writing Readable, Maintainable Code

Comments: explain what code does — helps other developers and your future self
Meaningful variable names: studentScore not x — makes code self-documenting
Indentation: code inside IF, loops and subroutines should be indented — shows structure at a glance
Subroutines: break code into small, testable procedures and functions — easier to debug and maintain
Constants: use named constants (e.g. MAX_SIZE) instead of hard-coded numbers — easy to change
Exam Practice

Have a go at this question

Cambridge IGCSE 0478 style
A program accepts a temperature value between -50 and 50. State three items of test data you would use to test the validation of this input and state the type of each.
6 marks
Normal data: 20 (a valid mid-range value) [1] — expected to be accepted [1]. Boundary data: -50 or 50 (at the limits of valid range) [1] — expected to be accepted [1]. Erroneous data: 100 or "hot" (outside valid range or wrong type) [1] — expected to be rejected [1].
Key Takeaways

What to Remember

Syntax error: breaks the rules → won't run. Logic error: runs but wrong output. Runtime: crashes mid-run.
Test data: Normal (typical), Boundary (at limits), Erroneous (invalid — should be rejected)
Good practice: comments, meaningful names, indentation, subroutines, constants
Trace table: step through program manually with test values to find logic errors