Manuel Lemos posted a very interesting article on defensive programming techniques. Things goes when PHPClasses newsletter faced some technical problems in delivery, but thanks to defensive programming “no harm was done. It only caused a delay in the delivery of the newsletters that were left in the queue for several days”. An interesting experience I can say because there are unexpected things that might happen to your site, and using some best practice programming techniques you can prevent the worst from happening. Manuel recommends to :
- Handle unexpected conditions
- Process external systems data properly
- Test your code
- Monitor your site errors and act upon them
- Do not disclose errors to the users
- Damage control
- Backup
- Do what you can as you can never get defensive enough