Member-only story
Dependency Inversion vs. Dependency Injection
Straightforward and simple
I’ve been a software engineer for a few years now, yet every now and then I like to return to the fundamentals. We all “know” that we should follow the SOLID principles by good ol’ Uncle Bob, but common knowledge is not always common practice.
Recently, it dawned on me that I don’t really know the difference between dependency inversion and dependency injection. I know what they mean, roughly, but I wasn’t sure what’s the difference between the two, and moreover, why is it called dependency inversion, what exactly is inverted?
It turns out, like all good things, there’s a story behind it.
But first things first, let’s discuss the difference between the two concepts.

Dependency Inversion
Dependency inversion is a design principle. In simple terms, it means we should not depend on low-level implementations, but rather rely on high-level abstractions. And that makes sense, as it allows us to be agnostic towards the implementation details. Whether we want to change a specific implementation or support other…