Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 483
Oren A Avatar asked Sep 23 '10 16:09

Oren A


People also ask

What are high level modules and low-level modules?

High-level modules contain the important policy decisions and business models of an application – The identity of the application. Low-level modules contain detailed implementations of individual mechanisms needed to realize the policy.

What is high level module in dependency inversion?

Definition of the Dependency Inversion Principle The general idea of this principle is as simple as it is important: High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features.

What are high level modules in programming?

High level module is the interface / abstraction that will be consumed directly by the presentation layer. Low level on the other hand are bunch of small modules (subsystems) help the high level do their work.

What is high level and low-level class?

Low level classes are the simple workers that perform actions, while high level classes are the management class that orchestrate the low level classes. For example, if you have a class that reads bytes from a file and a class that calculates the CRC of bytes, they are low level classes because each performs an action.


2 Answers

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.

like image 153
Femaref Avatar answered Nov 13 '22 07:11

Femaref


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.

like image 42
Jana Filipenská Avatar answered Nov 13 '22 06:11

Jana Filipenská