principles:liskov_substitution_principle
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
principles:liskov_substitution_principle [2013-01-15 17:06] – created christian | 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 11: | Line 11: | ||
===== Principle Statement ===== | ===== Principle Statement ===== | ||
+ | > " | ||
===== Description ===== | ===== Description ===== | ||
Line 19: | Line 20: | ||
===== Strategies ===== | ===== Strategies ===== | ||
+ | |||
+ | * Only strengthen invariants in subclasses; never weaken them | ||
+ | * Only waken preconditions 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: // | ||
Line 41: | Line 54: | ||
==== Contrary Principles ==== | ==== Contrary Principles ==== | ||
- | * [[principles:Keep It Simple Stupid]] | + | * [[Keep It Simple Stupid]] |
==== Complementary Principles ==== | ==== Complementary Principles ==== | ||
- | * [[principles: | + | * [[Model Principle]] (MP): MP demands inheritance relations to resemble an " |
- | * [[principles: | + | * [[Principle |
==== Principle Collections ==== | ==== Principle Collections ==== | ||
Line 52: | Line 65: | ||
{{page> | {{page> | ||
{{page> | {{page> | ||
+ | |||
===== Example ===== | ===== Example ===== | ||
Line 61: | Line 75: | ||
/ | / | ||
/ | / | ||
+ | |||
===== Further Reading ===== | ===== Further Reading ===== | ||
- | * Robert C. Martin: //Agile Software Development, | + | * Robert C. Martin: //Agile Software Development, |
* [[http:// | * [[http:// | ||
+ | * [[wiki> | ||
+ | * [[wp> | ||
+ |
principles/liskov_substitution_principle.txt · Last modified: 2021-10-18 21:50 by christian