CSC/ECE 517 Fall 2007/wiki2 9 kk: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Principle of Least Astonishment = | |||
The principle of least astonishment states that when you are presented with a different outcomes one should always pick the one of least ambiguity or suprise. The principle has applications in a lot of fields. This wiki serves as a guide for the reader to understand more about this principle. | The principle of least astonishment states that when you are presented with a different outcomes one should always pick the one of least ambiguity or suprise. The principle has applications in a lot of fields. This wiki serves as a guide for the reader to understand more about this principle. | ||
== Examples == | |||
The simplest example in programming where the name of a function does not indicate its functionality. | |||
{ | |||
int add(int a, int b) | |||
<nowiki>{ | |||
return (a*a+b*b); | |||
}</nowiki> | |||
} | |||
The function above is supposed to add two numbers but actualy returns the sum of squares of the two numbers which would suprise the programmer who is using the function. | |||
== Application in Programming == | |||
== Applications in Other Fields == |
Revision as of 16:25, 24 October 2007
Principle of Least Astonishment
The principle of least astonishment states that when you are presented with a different outcomes one should always pick the one of least ambiguity or suprise. The principle has applications in a lot of fields. This wiki serves as a guide for the reader to understand more about this principle.
Examples
The simplest example in programming where the name of a function does not indicate its functionality.
{ int add(int a, int b) { return (a*a+b*b); }
}
The function above is supposed to add two numbers but actualy returns the sum of squares of the two numbers which would suprise the programmer who is using the function.