2 ms·
Well it would have been nice if he stated his interpretation of the Liskov Substitution Principle. The way i understood it best was here [1]. A subclass should
by splittingTimes 7y ago
Well it would have been nice if he stated his interpretation of the Liskov Substitution Principle. The way i understood it best was here [1].
A subclass should behave in a way that it never cause problems when it is used instead of the base class.
In concrete terms:
* No new exceptions are allowed to be thrown, unless they are subtypes of the exception thrown by the base class
* Preconditions cannot be strengthend by the subtype
* Postconditions cannot be weakened by the subtype
For me it is really the focus of using inheritance only if you want substitutability. Otherwise go with composition.
===
[1] https://youtu.be/8ZJ8BVlDIQ4?t=1762 https://youtu.be/8ZJ8BVlDIQ4?t=1762