principles:invariant_avoidance_principle
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
principles:invariant_avoidance_principle [2021-09-02 12:37] – old revision restored (2021-05-11 21:58) 65.21.179.175 | principles:invariant_avoidance_principle [2021-10-18 21:53] (current) – +++ restored +++ christian | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Invariant Avoidance Principle ====== | + | ====== Invariant Avoidance Principle |
===== Variants and Alternative Names ===== | ===== Variants and Alternative Names ===== | ||
Line 6: | Line 6: | ||
===== Context ===== | ===== Context ===== | ||
/* fill in contexts here: */ | /* fill in contexts here: */ | ||
- | * [[contexts: | + | * [[contexts: |
===== Principle Statement ===== | ===== Principle Statement ===== | ||
Line 18: | Line 17: | ||
Methods typically have preconditions. Something that has to be true prior to invoking the method so it can work properly. Typical cases are parameters that may not be '' | Methods typically have preconditions. Something that has to be true prior to invoking the method so it can work properly. Typical cases are parameters that may not be '' | ||
- | Furthermore there are (class) invariants, i.e. conditions that have to be true in all observable states during the whole lifetime of an object. Typical invariants are attributes that may not be '' | + | Furthermore there are (class) invariants, i.e. conditions that have to be true in all observable states during the whole lifetime of an object. Typical invariants are attributes that may not be '' |
While preconditions and invariants are absolutely necessary, introducing further ones comes at a certain cost. | While preconditions and invariants are absolutely necessary, introducing further ones comes at a certain cost. | ||
Line 48: | Line 47: | ||
===== Origin ===== | ===== Origin ===== | ||
- | This principle is newly introduced here. | + | {{page> |
Line 77: | Line 76: | ||
* [[Information Hiding/ | * [[Information Hiding/ | ||
- | * [[Liskov Substitution Principle]] (LSP): | + | * [[Liskov Substitution Principle]] (LSP): |
* [[Fail Fast]] (FF): Breaking an invariant is a defect. And in such a case the software should fail fast. | * [[Fail Fast]] (FF): Breaking an invariant is a defect. And in such a case the software should fail fast. | ||
* [[Don' | * [[Don' | ||
+ | * [[Low Coupling]] (LC): One type of precondition is that a specific method has to be called prior to another one. This also results in a temporal coupling. | ||
==== Principle Collections ==== | ==== Principle Collections ==== | ||
Line 140: | Line 140: | ||
==== Example 3: C++ References ==== | ==== Example 3: C++ References ==== | ||
- | Sompare | + | Compare |
<code c++> | <code c++> | ||
Line 174: | Line 174: | ||
/* Choose one of the following and comment out the rest: */ | /* Choose one of the following and comment out the rest: */ | ||
/ | / | ||
- | [[wiki: | + | /*[[wiki: |
- | /*[[wiki: | + | [[wiki: |
===== Further Reading ===== | ===== Further Reading ===== | ||
+ | * {{page> | ||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | Discuss this wiki article and the principle on the corresponding [[talk: | ||
principles/invariant_avoidance_principle.txt · Last modified: 2021-10-18 21:53 by christian