User Tools

Site Tools


principles:principle_of_least_surprise

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
principles:principle_of_least_surprise [2020-10-12 16:31] – old revision restored (2013-02-11 15:03) 159.69.186.191principles:principle_of_least_surprise [2021-09-02 10:48] – old revision restored (2021-05-11 22:18) 65.21.179.175
Line 25: Line 25:
  
 ===== Strategies ===== ===== Strategies =====
 +
 +  * Separate methods that change an object (commands) from methods asking the object a question (queries) (see [[Command-Query Separation|CQS]])
 +    * This especially means that a query method should not alter the observable object state
 +  * Name all modules in a way that clearly communicates what the module is and does
 +    * Names of classes shall be nouns representing a specific (real-world) concept (see [[Model Principle|MP]])
 +    * Names of ''interfaces'' shall be adjectives describing a specific property. This typically results in names ending with -able
 +    * Names of command methods shall be verbs (in imperative form)
 +    * Names of query methods shall start with get- or is-
 +    * Names of mathematical functions or the like shall be named by the respective concept (like ''sqrt'')
 +    * ...
 +  * Avoid "clever" solutions which are hard to grasp in favor of simple, dumb ones (see [[Keep It Simple Stupid|KISS]])
 +    * [[When in doubt, use brute force]]((http://www.catb.org/~esr/writings/taoup/html/ch01s06.html))
 +    * Tend to use the first solution that comes in mind
 +
 +===== Caveats =====
 +
 +See section [[#contrary principles]].
  
  
Line 48: Line 65:
 ==== Specializations ==== ==== Specializations ====
  
 +  * [[Command-Query Separation]] (CQS)
 ==== Contrary Principles ==== ==== Contrary Principles ====
  
Line 61: Line 79:
 {{page>collections:Unix Philosophy (Eric S. Raymond)#Box}} {{page>collections:Unix Philosophy (Eric S. Raymond)#Box}}
  
-===== Example =====+===== Examples =====
  
  
principles/principle_of_least_surprise.txt · Last modified: 2021-10-18 22:15 by christian