Friday, 6 July 2012

What is Liskov's Substitution Principle?

Derived types must be completely substitutable for their base types.

Very similar to the Open-Close principle since it says that we have to make sure that new classes that are derived from a base implementation are extending the parent without changing behavior. The new derived classes should be able to replace the base classes without any change in the code. For example if a parameter is an integer value type called hours the overridden method in the new concrete implementation should not suddenly want minutes. 

No comments:

Post a Comment