In focussing on the main logic of a program, programmers
may fail to take into account abnormal situations,
such as invalid data input, or a hard disk
becoming full. As a result, their programs are vulnerable to unexpected events or
conditions. In essence, such programs have holes in their defenses.

In particular, interfaces between programs are some of the
most error-prone areas in a system. One often-cited study
found that 39% of all software errors were internal interface
errors, i.e., errors in communication between programs.

Clearly to ensure more robust programs, we need not only
to protect ourselves from our own mistakes, but also to isolate
our programs from the potential errors of others. We
refer to this approach as Defensive Programming.

There are various causes of program malfunction that we can defend against:

DP-1: Parameter Not Checked A parameter received by a program is used without first checking if its contents are present and within the expected range.