Even better than good error messages is preventing a problem from occurring in the first place.
Error-prone situations that frequently cause problems or create problems with serious consequences should be removed through redesign. Some are easy to find (e.g., everytime the user is asked to spell out something, there is a risk of spelling errors, so use a menu), whereas, others must be identified through user testing of the interface. Use confirmation ("are you sure statement") for situations when the user issues a command that is either irrecoverable or whose results might cause undue alarm. However, the use of confirmation dialogues should be minimized and only appear when they are unexpected. Overuse will cause the user to dismiss them without a glance. When an unexpected dangerous situation appears, which should be brought to the user's attention, it may be dismissed just because this has become the routine action by the user. Even better than confirmations is to make the user's actions reversible.
Modes are a frequent source of user error and frustration and should be avoided if possible. Modes basically divide the user actions such that all actions are not accessible all of the time. This can be frustrating. Also, modes makes it possible for the user action in different ways depending on the current mode, which will often lead to user errors (i.e. Consistency).
If modes cannot be avoided totally, one can at least prevent many mode errors by explicitly recognizing the modes in the interface design. By showing states clearly and distinctly to the user, a designer can follow the principle of providing feedback, and thus make it less likely that the user will mistake the current mode. In addition to having clear status indicators showing the current mode, the interface should also exhibit clear differences between user actions in different modes to minimize the risk of confusing individual interface elements. Similarly, system feedback should be sufficiently varied to provide additional differentiation between modes. Mode confusion can also be prevented by the use of so-called spring-loaded modes where the users are only in the mode as long as they actively hold down a button or perform some other action that will automatically take them out of the mode as soon as they let go.