principles:liskov_substitution_principle
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
principles:liskov_substitution_principle [2020-10-12 16:23] – old revision restored (2013-06-15 15:38) 159.69.186.191 | principles:liskov_substitution_principle [2021-09-02 18:26] – old revision restored (2021-09-02 10:48) 65.21.179.175 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Liskov Substitution Principle | + | ====== Liskov Substitution 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: |
- | * [[contexts: | + | |
===== Principle Statement ===== | ===== Principle Statement ===== | ||
- | |||
- | > " | ||
===== Description ===== | ===== Description ===== | ||
- | |||
- | Object-oriented programming languages allow to derive subtypes from base types and subtype polymorphism allows to pass an object of a subtype where ever an object of the supertype is specified. Suppose '' | ||
- | |||
- | But the programming language does not enforce that the subtype also behaves like the supertype. Method '' | ||
- | |||
- | |||
Line 32: | Line 23: | ||
* Only waken preconditions when overriding methods | * Only waken preconditions when overriding methods | ||
* Only strengthen postconditions when overriding methods | * Only strengthen postconditions when overriding methods | ||
- | * Use Delegation instead of Inheritance | ||
- | * Figure out better abstractions | ||
- | |||
- | ===== Caveats ===== | ||
- | |||
- | See section [[#contrary principles]]. | ||
- | |||
- | |||
===== Origin ===== | ===== Origin ===== | ||
- | |||
- | Barbara Liskov: // | ||
===== Evidence ===== | ===== Evidence ===== | ||
/* Comment out what is not applicable and explain the rest: */ | /* Comment out what is not applicable and explain the rest: */ | ||
- | + | /* | |
- | /* * [[wiki: | + | * [[wiki: |
- | + | * [[wiki: | |
- | * [[wiki: | + | * [[wiki: |
- | * [[wiki: | + | * [[wiki: |
- | + | */ | |
- | /* * [[wiki: | + | |
===== Relations to Other Principles ===== | ===== Relations to Other Principles ===== | ||
Line 67: | Line 47: | ||
==== Complementary Principles ==== | ==== Complementary Principles ==== | ||
- | * [[Model Principle]] (MP): MP demands inheritance relations to resemble an " | + | |
+ | * [[Invariant Avoidance Principle]] FIXME | ||
+ | | ||
* [[Principle of Separate Understandability]] (PSU): When building inheritance hierarchies, | * [[Principle of Separate Understandability]] (PSU): When building inheritance hierarchies, | ||
Line 75: | Line 57: | ||
{{page> | {{page> | ||
- | + | ===== Example | |
- | ===== Examples | + | |
Line 84: | Line 65: | ||
/ | / | ||
/ | / | ||
- | |||
===== Further Reading ===== | ===== Further Reading ===== | ||
- | * Robert C. Martin: //Agile Software Development, | + | * Robert C. Martin: //Agile Software Development, |
* [[http:// | * [[http:// | ||
- | * [[wiki> | ||
- | * [[wp> | ||
- | * Barbara H. Liskov , Jeanette M. Wing: // | ||
- | * Barbara H. Liskov , Jeanette M. Wing: // |
principles/liskov_substitution_principle.txt · Last modified: 2021-10-18 21:50 by christian