What is Liskov's Substitution Principle? - C# Gotcha! Interview Questions
Channel: Ryan McBeth
Date: 2021-03-15

The Liskov Substitution Principal is named after MIT Professor Dr. Barbara Liskov.

If you take away all the math, the principle basically states that if you have a parent class and a child class being passed into a method, then those two classes must behave exactly the same.

Here's what happens when they are not the same:  A square is a type of rectangle, so at first glance, it may make sense to derive a square from a rectangle.  But if you do this, you violate Liskov's Substitution Principle because a square will have extra properties that it does not need... which could result in the kind of bugs that could destroy the world.

Code for the big board used in this tutorial are at my Github below.

https://github.com/mcbethr/BigBoard
ryanmcbeth.com

And if you've never seen Dr. Strangelove, you should.  It's a classic.

Pentagon Image credit gregwest98
https://www.flickr.com/photos/10206399@N00