2 ms·
You're correct. From Wikipedia[0]: > Liskov's notion of a behavioral subtype defines a notion of substitutability for mutable objects; that is, if S is a subt
by ethagnawl 10y ago
You're correct.
From Wikipedia[0]:
> Liskov's notion of a behavioral subtype defines a notion of substitutability for mutable objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g. correctness).
0: https://en.wikipedia.org/wiki/Liskov_substitution_principle https://en.wikipedia.org/wiki/Liskov_substitution_principle
- Ntrails 10y agoSurely it follows logically anyway? Assuming sub/super are referring to inheritance (sorry, I'm a bad), a sub contains all of a super and more. Passing through an object with more shouldn't break anything. But a super might lack things the sub has, thereby breaking assumptions about what will be present. I feel like the principle would be broken by the objects/inheritance being badly used rather than the calling code though?
- talideon 10y agoLSP doesn't specifically deal with inheritance; it's equally applicable to interface implementation.
- coderjean1 10y agoYes you are totally right. I mistyped a word. Where it says supertype I actually meant subtype. I corrected the article.