Posts

Showing posts with the label functional

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

Image
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 corr...

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

Image
  Notepad++ is a great and free text editor with many practical features, such as line-sorting, multi-file and directory find-and-replace, and excellent encoding support. However, programming is hard, and even the noble Notepad++ has been caught off guard in the war on bugs:  To NULL or not to NULL... A display full of NULLs is not that desirable, but on the other hand is better than random, uninitialized data, or worse, reading beyond assigned buffers into memory regions containing data this user is not supposed to see.  The history of NULL is a controversial one: it was, somewhat like JavaScript, cheap to implement at the time and seemed a good idea. However, notoriously, even the inventor of NULL considers the invention to be a mistake . At first glance, and when used in a very limited scope, NULL seems a sensible construct: a global kind of default 'this is not set' value, that is reliably detectable, as opposed to some random memory garbage. Issues arise when the NU...