1. Validate input, expect all external input (both human and machine generated) to be completely bogus.
2. Fail fast and early. If something seems off, crash straight away, and do not expect things to magically repair itself at a later stage.
3. Use pre- and post-conditions where appropriate.
I'm not sure about the exact definitions of defensive programming, but static type checking, and possibly unit testing, might also be part of it.
1. Validate input, expect all external input (both human and machine generated) to be completely bogus.
2. Fail fast and early. If something seems off, crash straight away, and do not expect things to magically repair itself at a later stage.
3. Use pre- and post-conditions where appropriate.
I'm not sure about the exact definitions of defensive programming, but static type checking, and possibly unit testing, might also be part of it.