Oren A
Oren A

Reputation: 5900

What are "High-level modules" and "low-level modules" (in the context of Dependency inversion principle)?

I was reading Wikipedia's definition of Dependency inversion principle, and it uses two terms High-level modules and low-level modules, which I wasn't able to figure out.

What are they and what does Dependency inversion principle have to do with them?

Upvotes: 25

Views: 8010

Answers (3)

jafar_aml
jafar_aml

Reputation: 369

There is a good article about Clean Architecture, I think it explains this question also.

" The outermost layer is the lowest level of the software and as we move in deeper, the level will be higher. "

The Clean Architecture — Beginner’s Guide

Upvotes: 0

Jana Filipenská
Jana Filipenská

Reputation: 361

This is explained here: https://softwareengineering.stackexchange.com/a/419630

Low level modules are "low level" because they have no dependencies, or no relevant dependencies. Very often, they can be easily reused in different contexts without introducing any separate, formal interfaces - which means, reusing them is straightforward, simple and does not require any Dependency Inversion.

High level modules, however, are "high level", because they require other, lower level modules to work. But if they are tied to a specific low-level implementation, this often prevents to reuse them in a different context.

Upvotes: 5

Femaref
Femaref

Reputation: 61477

The definition of those are given in the introductory sentence:

high level: policy setting
low level: dependency modules.

In laymen's terms: high level modules depend on low level modules, but shouldn't depend on their implementation. This can be achieved by using interfaces, thus decoupling the definition of the service from the implementation.

Upvotes: 12

Related Questions