22

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?

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
Oren A
  • 5,870
  • 6
  • 43
  • 64
  • possible duplicate of [Abstractions should not depend upon details. Details should depend upon abstractions?](http://stackoverflow.com/questions/1710005/abstractions-should-not-depend-upon-details-details-should-depend-upon-abstract) – Steven Apr 24 '14 at 14:18
  • In this answer there is a good example: https://stackoverflow.com/a/16579813/3415073 – Krusty Sep 17 '18 at 10:32

2 Answers2

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.

Femaref
  • 60,705
  • 7
  • 138
  • 176
  • What do they mean "Module" in this situation, because when i hear Module i think of Module32First/Next, .Dll file. –  Apr 09 '13 at 10:37
  • 1
    Any functionality that is encapsulated. For example: Business logic depends on database access. Both are modules of the software. – Femaref Apr 09 '13 at 10:46
  • Do you got an easier example for me ? i don't know what is Business logic. –  Apr 09 '13 at 16:41
  • 2
    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. – Femaref Apr 09 '13 at 17:11
  • I am not sure why they didn't upvote your question but hey I just did :) – Tarik Aug 07 '13 at 18:59
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.