Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That is an incorrect characterization of dependency injection. It is not that you have one implementation of a particular interface that changes over time; rather, it is possible that there will be many different implementations of an interface all at once, and which implementation will be used can vary over multiple different runs of the program. For example, in your actual program, you might want to use one implementation, while during unit testing, you might want to "mock out" that implementation with an alternative version that is easier to test. In this case, refactoring is not a solution, because you need to be able to test all the time without interrupting the rest of the development process.</p> <p>It should also be noted that dependency injection is usually used as a solution to the Singleton anti-pattern; it allows one to have a singleton object that can be easily mocked out during testing. And, if later it turns out that the singleton assumption really is incorrect, that singleton can be replaced with various implementations.</p> <p>Some resources which you may find helpful in better understanding the topic:</p> <ul> <li><a href="http://www.youtube.com/watch?v=8RGhT-YySDY" rel="nofollow noreferrer">Java on Guice: Dependency Injection the Java Way</a></li> <li><a href="http://www.youtube.com/watch?v=hBVJbzAagfs" rel="nofollow noreferrer">Big Modular Java with Google Guice</a></li> <li><a href="http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/" rel="nofollow noreferrer">Singletons are Pathological Liars</a></li> <li><a href="http://blogs.msdn.com/scottdensmore/archive/2004/05/25/140827.aspx" rel="nofollow noreferrer">Why Singletons are Evil</a></li> <li><a href="http://misko.hevery.com/2008/08/25/root-cause-of-singletons/" rel="nofollow noreferrer">Root Cause of Singletons</a></li> <li><a href="http://misko.hevery.com/2008/10/21/dependency-injection-myth-reference-passing/" rel="nofollow noreferrer">Dependency Injection Myth: Reference Passing</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload