What is Inverted in the Dependency Inversion Principle?

After years of experience, I found the concept of inversion difficult for many to understand. I recently discovered a new and very effective way to explain it that will help you understand it fully.

David Rodenas PhD

--

Photo by Rob Potter on Unsplash

It seems strange because it talks about inversion, which implies something is upside-down. Although this is true to some extent, what we’re actually turning is something that should be reversed inherently.

Un-inverted dependencies

To understand correctly what an inverted dependency or inverted control means, we need to first understand what we mean when it is not inverted.

An example is better than a thousand words; let’s start with one of the oldest examples I can find: a menu.

In this example, the function moviesMenu asks for options and then, based on the user’s selection, it executes the function addMovie or the function listMovies. We can…

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (6)