Defensive programming

Defensive programming is a form of defensive design🡭 intended to ensure the continuing function of a piece of software🡭 under unforeseen circumstances. Defensive programming practices are often used where high availability🡭 , safety🡭 , or security🡭 is needed.

Defensive programming is an approach to improve software and source code🡭 , in terms of:

  • General quality – reducing the number of software bugs🡭 and problems.
  • Making the source code comprehensible – the source code should be readable and understandable so it is approved in a code audit🡭 .
  • Making the software behave in a predictable manner despite unexpected inputs or user actions.