Defensive Design

Computer ScienceOCRGCSEUnit: 3.2 Programming
Free taster
5 of 6 sections open
The basics

Building Software Armour

Building Software Armour

Defensive design is programming like a pessimist - assuming everything that can go wrong, will go wrong. It's like building a castle with thick walls, a moat, and guards. You don't wait for attackers - you prepare for them. This means checking inputs, handling errors gracefully, and writing code others can understand. A good programmer doesn't trust users to enter sensible data or other programmers to use functions correctly!
Exam tip

Earn the mark scheme marks

Exam Tips

  • Validation vs Sanitisation: Validation checks data is acceptable; sanitisation cleans/removes dangerous content
  • Why maintain? Other programmers may need to update your code
  • Link to security: Input sanitisation prevents SQL injection and XSS attacks

Now try it yourself

Quiz · Question 1 of 15

What is the purpose of input validation in a program?

Tap an answer to check it

Revise every Computer Science topic, free during alpha

Defensive Design is one of 60 topics on PrepWise — all aligned to your exam board.

Start revising free →