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

2

23

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?

Donettedoney answered 23/9, 2010 at 16:15 Comment(2)
possible duplicate of Abstractions should not depend upon details. Details should depend upon abstractions?Feck
In this answer there is a good example: https://mcmap.net/q/417198/-what-is-high-level-modules-and-low-level-modulesColorfast
C
11

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.

Cervantez answered 23/9, 2010 at 16:22 Comment(5)
What do they mean "Module" in this situation, because when i hear Module i think of Module32First/Next, .Dll file.Jefferyjeffie
Any functionality that is encapsulated. For example: Business logic depends on database access. Both are modules of the software.Cervantez
Do you got an easier example for me ? i don't know what is Business logic.Jefferyjeffie
Imagine you want to write something on a piece of paper. Your hand is a module, and the pen is a module. Both don't need each other to exist, but the hand can use the pen.Cervantez
I am not sure why they didn't upvote your question but hey I just did :)Tramline
H
3

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.

Hydrant answered 14/5, 2022 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.