Defensive programming with expectations