Question

Dependency Inversion Principle states: High-level modules should not depend on low-level modules.

With that in mind, my old:

UI -> Business Logic Layer -> Data Access Layer

became

UI -> Business Logic Layer <- Data Access Layer

I kept the UI depending on the business logic layer so I can easily attach another UI implementation. My business logic layer is the brain.

But does that breaks Dependency Inversion Principle? UI is higher level than Business Logic, right?

Thanks for helping.

Was it helpful?

Solution

The high or low-level modules in the Dependecy Inversion regards implementation detail. Take its principles for instance. The principle states:

A. High-level modules should not depend on low-level modules. Both should depend on abstractions.

B. Abstractions should not depend upon details. Details should depend upon abstractions.

It does not matter which modules, or layers, are taking into account when evaluating the Dependecy Invertion Principle. You can have high-level UI and low-level UI. The point of this principle is that your high-level UI should not rely upon low-level Business Logic Layer, anything else among high-level modules is OK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top