From Wikipedia,
Liskov's notion of a behavioral subtype defines a notion of substitutability for objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g. correctness).
Suppose the following class hierarchy:
- The base abstract class -
AnimalWithFur. It has a read-only propertyfurColorthat is overridden in successors. - Base class's successor -
Cat, which overridesfurColorand returns gray. - Cat's successor -
Tiger, which overridesfurColorand returns striped.
Then we declare a method with an argument of type Cat (not AnimalWithFur).
Is sending a Tiger instance to that method a violation of the L in SOLID?