example is the specification of a filename - much trouble can be averted. The
defensive programmer works on the assumption that when the user is asked
to press any key, he/she might possibly press the Esc or Break key, that a user
will sometimes type a letter O in place of digit zero, that the wrong data
might be placed in a field, or that a global variable might have an unexpected
value. Allowing for these probabilities (they are not just possibilities) can
make a program much more user-proof and tolerant, and hence easier to use.
There are programs in everyday use that pundits dismiss as unfriendly and
old-fashioned, but
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.