...

/

The Dependency Inversion Principle

The Dependency Inversion Principle

Learn about the dependency inversion principle and how it can help you develop clean software architecture.

Dependency in layered architecture

In our layered architecture, the cross-layer dependencies always point downward to the next layer. When we apply the Single Responsibility Principle on a high level, we notice that the upper layers have more reasons to change than the lower layers.

Thus, due to the domain layer’s dependency to the persistence layer, each change in the persistence layer potentially requires a change in the domain layer. But the domain code is the most important code in our application! We don’t want to have to change it when something changes in the persistence code!

How can we get rid of this dependency?

The Dependency Inversion Principle provides the answer.

In contrast to ...