Briefly Exploring the Similarities Between LSP and DIP

Jul 29 2016

What is the relationship between the Dependency Inversion Principle and the Liskov Substitution Principle?

One common thread is dependencies.

Obviously, DIP is about dependencies. It is in the name. The idea is to depend on abstractions instead of concretions. This allows us to substitute any implementation of that abstraction for another. (There are hints of LSP in there.)

But how is LSP about dependencies?

When we adhere to the Liskov Substitution Principle, we set ourselves up to depend on our base class – the abstraction, instead of a subclass – the concretion. (This sounds a lot like DIP.)

Both of these principles encourage flexibility when it comes to the modules that we depend on.

tags:SOLIDLSPDIP

Recent Articles