Software & Apps

The True Meaning of Inheritance · cekrem.github.io

After exploring Dependency Inversion and Interface Segregationwe will tackle perhaps the most misunderstood principle of SOLID: The Liskov Substitution Principle (LSP).

Again, kudos to Uncle Bob for reminding me about the importance of good software architecture in his classic Clean Architecture! That book was my main inspiration for this series. Without a clean architecture, we’ll all be building firmware (my paraphrased summary).

The Liskov Substitution Principle states that if S is a subtype of T, then objects of type T can be replaced by objects of type S without changing any desired properties of the program.

In simpler terms: subtypes must replace their base types. Let’s see what it really means in practice.

The Classic Rectangle-Square Problem