9/19/19 Liskov's Principle

So today we went over a whole slew of concepts and changed our programs about 3 times going through various ways of doing the same thing, but better and each time we used a concept that looks to be more maintanable and scalable. Instead of using If/then statements we now have entirely homebuilt commands that can be simply added in. It’s pretty cool.

We went over the SOLID concept as well and Tim wanted us to do a bit more research on Liskov’s principle and why using the analogy of a quadrilateral -> rectangle -> square is bad when talking about class inheritance. This concept kind of butts head with the way that we’ve been trained our entire lives from grade school up to think about geometry. In the example, the scope gets scaled down the further you go. To be a quadrilateral, you just need four sides of any length. Rectangles need to have a height and a width. Squares only have equal sides. This is the opposite of what inheritance says in that a child has to be able to take the place of the parent class. A square can’t have a different height or width and a rectangle has to have right angles so it can’t have individual side lengths. So a square could be a rectangle in the only instance of when you want equal side lengths. All other instances in which you want a rectangle, a square cannot take the place of a rectangle.

I hope I explained that coherently. One more day until the weekend and we can let our brain’s un-melt!

Written on September 19, 2019