E.Liskov's Substitution Principle(LSP)

  1. Summary

      1. Subclass(derived class) must be behaviorally equal to their base types.

      2. This principle is just an extension of the Open Close Principle and it means that we must make sure that new derived classes are extending the base classes without changing their behavior.

      3. Any overriding violates this principle to avoid overriding as long as you can.

      4. It recommend to prefer Delegation over Inheritance if you do not need to modify the behavior of other class.

      5. It recommend to prefer Composition over Aggregation

      6. Prefer Property Map instead of inheritance

      7. Inheritance should be last option for extension

      8. This is very important principle that if applied correctly then eliminate lot of problems so apply it very carefully.

  2. Applicability

      1. Class design.

  1. References