Some software has higher than usual requirements for availability, safety or security. Very often in such projects, people practice pragmatic paranoia and coding style called Defensive Programming.

The idea behind this approach is that your code should behave in a consistent and predictable manner even in the case of unexpected conditions. In practice, you will defend against the impossible, because things become possible when the outer world is changing: new people join the team, the code goes into maintenance, dependencies upgrade… Actually, humans make anything possible when it comes to errors.

Jim Bird has gathered a set of rules on how to employ Defensive Programming in your codebase: