Chapter 66. Prevent Errors

Giles Colborne

image with no caption

ERROR MESSAGES are the most critical interactions between the user and the rest of the system. They happen when communication between the user and the system is near the breaking point.

It is easy to think of an error as being caused by a wrong input from the user. But people make mistakes in predictable, systematic ways. So it is possible to “debug” the communication between the user and the rest of the system just as you would between other system components.

For instance, say you want the user to enter a date within an allowed range. Rather than letting the user enter any date, it is better to offer a device such as a list or calendar showing only the allowed dates. This eliminates any chance of the user entering a date outside of the range.

Formatting errors are another common problem. For instance, if a user is presented with a Date text field and enters an unambiguous date such as “July 29, 2012,” it is unreasonable to reject it simply because it is not in a preferred format (such as “DD/MM/YYYY”). It is worse still to reject “29 / 07 / 2012” because it contains extra spaces—this kind of problem is particularly hard for users to understand, as the date appears to be in the desired format.

This error occurs because it is easier to reject the date than parse the three or four most common date formats. These kinds of petty ...

Get 97 Things Every Programmer Should Know now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.