What Is The Difference Between The Liskov Substitution Principle and Dependency Inversion Principle?

Often Confused, Never Replaced

Steven Curtis
4 min readFeb 1, 2022
Photo by 愚木混株 cdd20 on Unsplash

The SOLID Principles consist of five principles for Object Oriented Design, written by Robert Cecil Martin.

I’ve found that two of the principles, the Liskov Substitution Principle and Dependency Inversion Principle both cover similar ground and can be confused.

This article is designed to disambiguate the two, and make it clear what those two principles are for and how they might help you as a software engineer.

The Liskov Substitution Principle

Functions that use pointers or references to base classes must be able to use objects of the derived classes without they are using a derived class.

In plain English, objects in a superclass should be replaceable with objects of it’s subclass.

The principle:

Objects of a superclass shall be replaceable…

--

--