Principle of least astonishment

Last updated

In user interface design and software design, [1] the principle of least astonishment (POLA), also known as principle of least surprise, [lower-alpha 1] proposes that a component of a system should behave in a way that most users will expect it to behave, and therefore not astonish or surprise users. The following is a corollary of the principle: "If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature." [4]

Contents

The principle has been in use in relation to computer interaction since at least the 1970s. Although first formalized in the field of computer technology, the principle can be applied broadly in other fields. For example, in writing, a cross-reference to another part of the work or a hyperlink should be phrased in a way that accurately tells the reader what to expect.

Origin

An early reference to the "Law of Least Astonishment" appeared in the PL/I Bulletin in 1967 (PL/I is a programming language released by IBM in 1966). [5] By the late 1960s, PL/I had become infamous for violating the law, [6] for example because, due to PL/I's precision conversion rules, [7] the expressions 25 + 1/3 and 1/3 + 25 would either produce a fatal error, or, if errors were suppressed, 5.33333333333 instead of the correct 25.33333333333. [8]

The law appeared written out in full in 1972:

For those parts of the system which cannot be adjusted to the peculiarities of the user, the designers of a systems programming language should obey the “Law of Least Astonishment.” In short, this law states that every construct in the system should behave exactly as its syntax suggests. Widely accepted conventions should be followed whenever possible, and exceptions to previously established rules of the language should be minimal. [9]

Formulation

A textbook formulation is: "People are part of the system. The design should match the user's experience, expectations, and mental models." [10]

The principle aims to leverage the existing knowledge of users to minimize the learning curve, for instance by designing interfaces that borrow heavily from "functionally similar or analogous programs with which your users are likely to be familiar". [2] User expectations in this respect may be closely related to a particular computing platform or tradition. For example, Unix command line programs are expected to follow certain conventions with respect to switches, [2] and widgets of Microsoft Windows programs are expected to follow certain conventions with respect to keyboard shortcuts. [11] In more abstract settings like an API, the expectation that function or method names intuitively match their behavior is another example. [12] This practice also involves the application of sensible defaults. [4]

When two elements of an interface conflict, or are ambiguous, the behavior should be that which will least surprise the user; in particular a programmer should try to think of the behavior that will least surprise someone who uses the program, rather than that behavior that is natural from knowing the inner workings of the program. [4]

The choice of "least surprising" behavior can depend on the expected audience (for example, end users, programmers, or system administrators). [2]

Examples

Websites offering keyboard shortcuts often allow pressing ? to see the available shortcuts. Examples include Gmail, [13] YouTube, [14] and Jira. [15]

In Windows operating systems and some desktop environments for Linux, the F1 function key typically opens the help program for an application. A similar keyboard shortcut in macOS is Command +⇧ Shift+/. Users expect a help window or context menu when they press the usual help shortcut key(s). Software that instead uses this shortcut for another feature is likely to cause astonishment if no help appears. [16]

A programming language's standard library usually provides a function similar to the pseudocode ParseInteger(string, radix), which creates a machine-readable integer from a string of human-readable digits. The radix conventionally defaults to 10, meaning the string is interpreted as decimal (base 10). This function usually supports other bases, like binary (base 2) and octal (base 8), but only when they are specified explicitly. In a departure from this convention, JavaScript originally defaulted to base 8 for strings beginning with "0", causing developer confusion and software bugs. [17] This was discouraged in ECMAScript 3 and dropped in ECMAScript 5. [18]

Some development communities like FreeBSD [19] use POLA as one of the guidelines for what makes an unsurprising user experience.

See also

Notes

  1. Alternatively a law of least surprise or rule of least surprise. [2] [3]

Related Research Articles

<span class="mw-page-title-main">Ada (programming language)</span> High-level programming language first released in 1980

Ada is a structured, statically typed, imperative, and object-oriented high-level programming language, inspired by Pascal and other languages. It has built-in language support for design by contract (DbC), extremely strong typing, explicit concurrency, tasks, synchronous message passing, protected objects, and non-determinism. Ada improves code safety and maintainability by using the compiler to find errors in favor of runtime errors. Ada is an international technical standard, jointly defined by the International Organization for Standardization (ISO), and the International Electrotechnical Commission (IEC). As of May 2023, the standard, called Ada 2022 informally, is ISO/IEC 8652:2023.

<span class="mw-page-title-main">APL (programming language)</span> Functional programming language for arrays

APL is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent most functions and operators, leading to very concise code. It has been an important influence on the development of concept modeling, spreadsheets, functional programming, and computer math packages. It has also inspired several other programming languages.

Mesa is a programming language developed in the mid 1970s at the Xerox Palo Alto Research Center in Palo Alto, California, United States. The language name was a pun based upon the programming language catchphrases of the time, because Mesa is a "high level" programming language.

Octal is a numeral system with eight as the base.

PL/I is a procedural, imperative computer programming language initially developed by IBM. It is designed for scientific, engineering, business and system programming. It has been in continuous use by academic, commercial and industrial organizations since it was introduced in the 1960s.

SNOBOL is a series of programming languages developed between 1962 and 1967 at AT&T Bell Laboratories by David J. Farber, Ralph Griswold and Ivan P. Polonsky, culminating in SNOBOL4. It was one of a number of text-string-oriented languages developed during the 1950s and 1960s; others included COMIT and TRAC.

In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an exception breaks the normal flow of execution and executes a pre-registered exception handler; the details of how this is done depend on whether it is a hardware or software exception and how the software exception is implemented.

In software engineering and computer science, abstraction is the process of generalizing concrete details, such as attributes, away from the study of objects and systems to focus attention on details of greater importance. Abstraction is a fundamental concept in computer science and software engineering, especially within the object-oriented programming paradigm. Examples of this include:

An object-oriented operating system is an operating system that is designed, structured, and operated using object-oriented programming principles.

<span class="mw-page-title-main">Keyboard shortcut</span> Series of computer keys to quickly invoke a software program or perform a preprogrammed action

In computing, a keyboard shortcut also known as hotkey is a series of one or several keys to quickly invoke a software program or perform a preprogrammed action. This action may be part of the standard functionality of the operating system or application program, or it may have been written by the user in a scripting language. Some integrated keyboards also include pointing devices; the definition of exactly what counts as a "key" sometimes differs.

In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors. Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that is, some facilities are type-safe and their usage will not result in type errors, while other facilities in the same language may be type-unsafe and a program using them may encounter type errors. The behaviors classified as type errors by a given programming language are usually those that result from attempts to perform operations on values that are not of the appropriate data type, e.g., adding a string to an integer when there's no definition on how to handle this case. This classification is partly based on opinion.

In computer software, a general-purpose programming language (GPL) is a programming language for building software in a wide variety of application domains. Conversely, a domain-specific programming language (DSL) is used within a specific area. For example, Python is a GPL, while SQL is a DSL for querying relational databases.

Extensible programming is a term used in computer science to describe a style of computer programming that focuses on mechanisms to extend the programming language, compiler, and runtime system (environment). Extensible programming languages, supporting this style of programming, were an active area of work in the 1960s, but the movement was marginalized in the 1970s. Extensible programming has become a topic of renewed interest in the 21st century.

DWIM computer systems attempt to anticipate what users intend to do, correcting trivial errors automatically rather than blindly executing users' explicit but potentially incorrect input.

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term usually refers to programming interfaces similar to the classic Lisp machine interactive environment. Common examples include command-line shells and similar environments for programming languages, and the technique is very characteristic of scripting languages.

<span class="mw-page-title-main">Rexx</span> Command/scripting/programming language

Rexx is a programming language that can be interpreted or compiled. It was developed at IBM by Mike Cowlishaw. It is a structured, high-level programming language designed for ease of learning and reading. Proprietary and open source Rexx interpreters exist for a wide range of computing platforms; compilers exist for IBM mainframe computers.

In computer science, region-based memory management is a type of memory management in which each allocated object is assigned to a region. A region, also called a zone, arena, area, or memory context, is a collection of allocated objects that can be efficiently reallocated or deallocated all at once. Memory allocators using region-based managements are often called area allocators, and when they work by only "bumping" a single pointer, as bump allocators.

Haskell is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell has pioneered a number of programming language features such as type classes, which enable type-safe operator overloading, and monadic input/output (IO). It is named after logician Haskell Curry. Haskell's main implementation is the Glasgow Haskell Compiler (GHC).

Gradual typing is a type system that lies inbetween static typing and in dynamic typing. Some variables and expressions may be given types and the correctness of the typing is checked at compile time and some expressions may be left untyped and eventual type errors are reported at runtime.

References

  1. Seebach, Peter (2001-08-01). "The Principle of Least Astonishment". The cranky user. IBM DeveloperWorks . Retrieved 2014-01-23.
  2. 1 2 3 4 Raymond, Eric Steven (2003). "Applying the Rule of Least Surprise". The Art of Unix Programming. faqs.org. p. 20. ISBN   978-0-13-142901-7 . Retrieved 2020-08-23.
  3. James, Geoffrey (1987). The Tao of Programming. InfoBooks. 4.1. ISBN   0-931137-07-1 . Retrieved 2014-02-05.
  4. 1 2 3 Cowlishaw, M. F. (1984). "The design of the REXX language" (PDF). IBM Systems Journal. 23 (4): 333. doi:10.1147/sj.234.0326 . Retrieved 2014-01-23. Could there be a high astonishment factor associated with the new feature? If a feature is accidentally misapplied by the user and causes what appears to him to be an unpredictable result, that feature has a high astonishment factor and is therefore undesirable. If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature.
  5. Southworth, R. N. (December 1967). Southworth, R. N. (ed.). "Proposal for PL/I Pseudo-name". ACM SIGPLAN Notices. 2 (12) (PL/I Bulletin no. 5 ed.): 6. doi:10.1145/1139502.1139504. ISSN   0362-1340. S2CID   12180929.
  6. Date, C. J. (11 February 2022). Database Dreaming Volume I: Relational Writings Revised and Revived. Technics Publications. Ch.2, Reference 36. ISBN   978-1-63462-984-3. As a friend of mine once remarked to me—this must have been sometime in the late 1960s—whatever else you might say about it, there's one thing that PL/I is most definitely not, and that's 'the language of least astonishment.'
  7. Tremblay, Jean-Paul; Sorenson, Paul G. (1985). The theory and practice of compiler writing. New York: McGraw-Hill. ISBN   9780070651616. PL/I is the major bad example here; it is strewn with constructs which do not do what the programmer thinks, as exemplified with FIXED division.
  8. Multiple sources:
    • Holt, Richard C. (May 1973). "Teaching the fatal disease: (or) introductory computer programming using PL/I". ACM SIGPLAN Notices. 8 (5): 8–23. doi:10.1145/986948.986950. unfortunately, the expression '25 + 1/3' yields 5.33333333333333
    • Golden, Donald (October 1980). "A plea for friendly software". ACM SIGSOFT Software Engineering Notes. 5 (4): 4–5. doi: 10.1145/1010884.1010885 . Lest the non-PL/I programmer come to the erroneous conclusion that PL/I is without flaws, consider the following examples of PL/I's hostility. The rules for type conversion in PL/I are enough to give programmers ulcers. What other language would produce a fatal error when evaluating the expression (25 + 1/3)? (Just as bad, if you suppress the error checking, the result of evaluating the expression is 5.3333...)
    • Stansifer, Ryan D. (1995). The Study of Programming Languages . Englewood Cliffs, N.J. : Prentice Hall. p. 123. ISBN   978-0-13-726936-5. PL/I is infamous in this regard, as it converts nearly any type into any other type, sometimes with surprising results. Consider the expression 1/3 + 25. In PL/I this expression has the value 5.33333333333. Why? One-third is computed to 15 digits of precision, 14 to the right of the decimal point. Then 25 is coerced to the same precision, losing the most significant digit 2! This does raise an error in PL/I, but the default is to ignore it. This first appeared in print in Barron 1968, where it is given as a violation of a folk law of language design: 'the law of least astonishment.'
    • "Enterprise PL/I for z/OS 5.3 - Language Reference" (PDF). IBM. March 2021. pp. 57–62. Consider the following expression: 25+1/3. The result of evaluating this expression is undefined and the FIXEDOVERFLOW condition is raised because FIXED division results in a value of maximum implementation defined precision. [...] The results of the two evaluations are reached as shown in Table 29.
  9. Bergeron, R.D.; Gannon, J.D.; Shecter, D.P.; Tompa, F.W.; Dam, A. Van (1972). "Systems Programming Languages". Advances in Computers. 12: 175–284. doi:10.1016/s0065-2458(08)60510-0. ISBN   9780120121120.
  10. Saltzer, J. H.; Kaashoek, Frans (2009). Principles of computer system design: an introduction. Morgan Kaufmann. p. 85. ISBN   978-0-12-374957-4.
  11. Petroutsos, Evangelos (2010). Mastering Microsoft Visual Basic 2010. Wiley. p. 133. ISBN   978-0-470-53287-4.
  12. Bloch, Joshua (2006). "How to design a good API and why it matters". Proceeding OOPSLA '06 Companion to the 21st ACM SIGPLAN symposium on Object-oriented programming systems, languages, and applications. Association for Computing Machinery. pp. 506–7. doi:10.1145/1176617.1176622. ISBN   1-59593-491-X. S2CID   27230400.
  13. Vivian (2013-06-21). "Keyboard shortcuts for Gmail". Google Inc. Retrieved 2013-07-27.
  14. "Keyboard shortcuts for YouTube - YouTube Help". support.google.com. Retrieved 2022-08-16.
  15. "Using Keyboard Shortcuts". Atlassian. Retrieved 2013-07-27.
  16. Keizer, G. (1 March 2010). "Microsoft: Don't press F1 key in Windows XP". Computerworld. Retrieved 10 Nov 2019.
  17. "Why does the radix for JavaScript's parseInt default to 8?". Stack Overflow. 8 April 2011.
  18. "parseInt()", Mozilla Developer Network (MDN), 15 March 2024, If the input string begins with "0" (a zero), radix is assumed to be 8 (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 clarifies that 10 (decimal) should be used, but not all browsers support this yet.
  19. "Frequently Asked Questions for FreeBSD 2.X, 3.X and 4.X". FreeBSD. 2002-06-11. Retrieved 2023-02-15.