Skip to main content
1 of 2
Zavior
  • 1.3k
  • 2
  • 11
  • 18

If you don't fulfill the contract that has been defined in the base class, things can silently fail when you get results that are off.

[LSP in wikipedia states][2]

  • Preconditions cannot be strengthened in a subtype.
  • Postconditions cannot be weakened in a subtype.
  • Invariants of the supertype must be preserved in a subtype.

Should any of these not hold, the caller might get a result he does not expect. [1]: http://programmers.stackexchange.com/questions/170138/is-this-a-violation-of-the-liskov-substitution-principle [2]: http://en.wikipedia.org/wiki/Liskov_substitution_principle

Zavior
  • 1.3k
  • 2
  • 11
  • 18