The Liskov Substitution Principle (LSP): functions that use pointers to base classes must be able to use objects of derived classes without knowing it.Subtype Requirement:
Let be a property provable about objects of type T. Then should be true for objects of type S where S is a subtype of T.
When first learning about object oriented programming, inheritance is usually described as an "is a" relationship. If a penguin "is a" bird, then the
Penguin
class should inherit from the Bird
class. The "is a" technique of determining inheritance relationships is
simple and useful, but occasionally results in bad use of inheritance.The Liskov Substitution Principle is a way of ensuring that inheritance is used correctly.
No comments:
Post a Comment