In his latest blog post today, Ivo Jansch takes a look a t a situation where a little "defensive programming" would have helped.
The problem appeared to be in our test code. The software had a 'test' mode for testing the mailing by sending it only to the author and a small test team. It appeared that for some reason, all test mails were being mailed to the customers as well.
This problem would not have appeared if we had applied what I would like to call 'defensive programming'.
A few weeks ago, we had a major problem with software we'd written for a client. It was software for sending mailings to the client's customers. Suddenly there were many reports of clients receiving multiple mailings instead of just one.
He shows code examples from this situation, pointing out where the issue lies - a bad check in an if() statement.