19 Best Practice: No Path to an Error
Let’s say you have a calculator that does square roots. If the display shows “-1”, and you press the “√x” key, you can assume that you’ll be getting some sort of error message or indication of an error. On a physical calculator, there are physical keys that are there all the time, so of course, someone can press the key that leads to an error.
But, in modern programming, the best practice is to give the user no path to an error. So, using the calculator example, in a calculator with a drawn keyboard, the best course would be to disable the “√x” key when the accumulator is negative, thus preventing the error condition in the first place. The rule is simple: Whenever possible, leave the user no path to an error condition. This will mean temporary disablement of buttons, menu items, and other controls and parts of controls.