Content deleted Content added
remove hyphen |
correction |
||
Line 8:
In [[Statically typed language|statically typed languages]] using dependency injection means a client only needs to declare the [[Interface (computing)|interfaces]] of the services it uses, rather than their concrete implementations, making it easier to change which services are used at runtime without recompiling.
Application frameworks often combine dependency injection with [[inversion of control]]. Under inversion of control, the framework first constructs an object (such as a controller), and then passes [[control flow]] to it. With dependency injection, the framework also instantiates the dependencies declared by the application object (often in the constructor method's parameters), and passes the dependencies into the object.<ref>{{cite web |title=Spring IoC Container |url=https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/beans.html |access-date=2023-05-23 |language=en }}</ref>
Dependency injection implements the idea of "inverting control over the implementations of dependencies", which is why certain Java frameworks generically name the concept "inversion of control" (not to be confused with [[Inversion_of_control|inversion of control flow]]).<ref name="FowlerDI-IOC">{{cite web |last1=Fowler |first1=Martin |title=Inversion of Control Containers and the Dependency Injection pattern |url=https://martinfowler.com/articles/injection.html#InversionOfControl |website=MartinFowler.com |access-date=4 June 2023}}</ref>
|