2 ms·
> Isn't that Inversion Of Control, not Dependency Injection? Dependency injection is one of the techniques used to implement inversion of control. > I've alwa
by rumanator 6y ago
> Isn't that Inversion Of Control, not Dependency Injection?
Dependency injection is one of the techniques used to implement inversion of control.
> I've always thought of Dependency Injection as about "declaring a class in terms of its dependencies' interfaces, but allowing a framework to take responsibility for instantiating the actual dependency objects" - whereas "a function that accepts a function" is IoC (e.g. https://kentcdodds.com/blog/inversion-of-control/ https://kentcdodds.com/blog/inversion-of-control/)
Nope, dependency injection is about passing dependencies to the objects that depends on them (i.e., inject the dependency), instead of letting the object itself instantiate them directly or actively request access to them.
You may or may not depend on a framework to manage dependencies (service locator) and pass them to instances (service injector) but those are just helper components that assist with the whole dependency injection workflow. The key point is that dependencies are passed to the objects that depends on them.