Interface programming and proper layering is the best defensive measure I can think of.
When you separate what is being done from how it is done, you leave yourself the ability to change implementations without affecting clients, until the interface changes.
If you need to change the interface, or if you end up with a new problem, all bets are disabled. No language has built-in clairvoyance.
duffymo
source share