The Dependency Inversion Principle
Explore the Dependency Inversion Principle to understand how inverting dependencies between domain and persistence layers improves modularity and reduces reasons for change. This lesson helps you grasp key concepts to separate concerns and create maintainable software architectures.
We'll cover the following...
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 ...