Thinking Defensively about Functions, Methods, and Input