Content deleted Content added
decap |
m Repair or remove missing or deleted templates |
||
Line 66:
Similarly, because dependency injection does not require any change in code behavior, it can be applied to legacy code as a [[Code refactoring|refactoring]]. This makes clients more independent and are easier to [[Unit testing|unit test]] in isolation, using [[Method stub|stubs]] or [[mock object]]s, that simulate other objects not under test.
This ease of testing is often the first benefit noticed when using dependency injection.<ref>{{
=== Disadvantages ===
Line 82:
* Interface injection, where the dependency's interface provides an injector method that will inject the dependency into any client passed to it.
In some frameworks, clients do not need to actively accept dependency injection at all. In [[Java (programming language)|Java]], for example, reflection can make private attributes public when testing and inject services directly.<ref>{{
=== Without dependency injection ===
|