January 26, 2019
The Principle of Least Surprise is a concept that is used to frame your mindset as you code.
If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature.
This principle is typically used for designers, to guide how they craft functionality (in the sense that the user should be able to reasonably correctly guess the result of an action), but it’s really useful for developers too.
The idea is that code should be organized according to where the reader will expect it to be, and it should operate as one would expect.
myFunc(arg1, null, arg2)), surprising return values (ie.