Understanding SOLID Principles: Dependency Inversion
dev.to
dev.to
This is simply wrong.
You can do dependency injection without a container (using factories, or link-time polymorphism).
Dependency inversion is a lot more general:
Depending on a header file (interface) instead of a specific implementation already is a kind of dependency inversion.
Having a language-independent IR in a compiler also counts as dependency inversion (compared to an implementation where the frontend calls the backend): it prevents dependencies between the frontend and the backend (whose reasons to change generally aren't correlated), by making everybody depend on the IR instead.
In this case the function signature corresponds to the class interface, and partial application corresponds with binding the injected dependencies passed via the constructor (using a factory, or dependency injection container etc).
- When trying to make code testable, it's easier to configure from the outside than inside.
There's no need to mention other topics like factories, DI containers, etc. All of those are obvious abstractions on top of the very simple idea.
My only criticism is about articles that confuse the principle with the means you use to obtain it. Yes, do talk about factories and containers, but separate them from the principle and keep in mind that there are many other ways to get it. You don't need a DI container.
Besides, it only provides you an specific kind of testability, that may or may not be the best way to test your code.