Visual Studio - the Case for Catastrophic Failure! (Error handling: Fail early, fail safe)

Visual Studio, that erstwhile desktop development tool used by millions of Windows based developers since the late '90s, has been through many a revision.

Unfortunately, like any complex piece of software, some of these interesting and progressive revisions also involved the odd regressive bug, where the tool hit an unexpected state that it cannot handle.


Words fail to describe
 

Catastrophic failure!

Catastrophic indeed! In classic application developed software, handling 'undefined' situations that are not expected, leads to undefined behavior, where no one really knows how the system will continue to behave. Such situations pose a danger to any data involved, such as documents that the user is editing, since at the very least, the user may lost their current unsaved changes. Worse, if the program continues its imperative path (where the computer is blindly following instructions given by the original authors of the software), then the data may actually become corrupted, possibly beyond even an editable, readable state. So, the application developer protects the user and their data by throwing an exception: this halts the program in its tracks, preventing any further undefined behavior, and minimizing the chance of corrupting the user's data. Unfortunately, this results in ugly error dialogs appearing to the user, as shown here. Like many decisions in engineering, this is a trade off, here between immediate user-interruption and possible loss of unsaved data, versus continuing and possibly losing the data entirely due to undefined behavior. Ugly, but true!

There are some interesting alternatives to the imperative programming model, where the machine is following given instrutions in an exactly literal manner.
 
A simple alternative is to reduce the level of state in the application: following functional programming, where data is immutable and moves through functions, not modifying, but producing new copies. Application errors are still possible, but data damage can be minimized if data is treated not as a single replaced unit but a stream of immutable copies. Additionally, for the human who is writing the code, functional programming can be simpler to reason about, as it avoid side effects between program modules caused by shared modifiable state.
 
Possibly the field of AI can be extended more into application logic itself, and so applications may in future gain a better capability to deal with unexpected situations, such as mistakes in the design of the application, or unexpected application or environmental states, and 'learn' how to deal with the unexpected, or even avoid them re-occurring. Then, undefined behavior would up to a certain tolerance no longer be a problem to 'shut down' via error dialogs, but a normal part of application construction.

Comments

Popular posts from this blog

null++ and its alternatives - NULL as an anti-pattern and some alternatives - stateless functional code

whoa! Chrome crash! - UX challenge of presenting a catastrophic failure

Windows Vista - reproducing 56.81 Shakespeares... - Operating Systems are complex and will always have bugs