SOLID Principle By Example (L)

Liskov Substitution

SubClass should be replaceable with base class without any behavior breaks.

Violates Liskuv

To fix above code, we can do something like this

Valid Liskuv

Coding to interface will be how to follow liskuv principle, always make sure that all functions in classes implements same interface will return same type; else you will find yourself violating liskuve or OCP.