The Liskov Substitution Principle

This blog post is an adaptation of an answer I posted to Programmers.Stack Exchange.  You can find the original post here

The Liskov Substitution Principle is one of the five major OO design principles described by the SOLID acronym.  Quite simply, it says that when we design our class hierarchy, child objects should behave like their parent objects.

An easy way to conceptualise the LSP is to imagine a scenario where the LSP is violated.  Consider the following:

Continue reading