Voting: Unterschied zwischen den Versionen

Aus Java Student User Group Austria - Java + JVM in Wien Österreich / Vienna Austria
Wechseln zu: Navigation, Suche
(ebBXlaSV)
(qSKfXaTezVwTUl)
Zeile 1: Zeile 1:
Whoever edits and publishes these artlices really knows what they're doing.
+
Here is a reiteration of what rlaely makes Dependency Injection (DI) worthwhile. First of all  IoC and DI is not the same thing. DI is one type of IoC (read ch. 4 of  Pro Spring ).Example:You have component CC, which needs to use a service of type SS. Of course, CC should ideally not need knowledge about any implementations of SS. One implementation of SS is called SImp. SImp can of course not have knowledge about where it should be used, so no references to CC within SImp.Now:  How can we make CC use SImp?  Well, in my opinion DI handles this very elegantly:It stands outside of both CC and SImp and creates (injects) the link (dependency) between the two.

Version vom 16. Dezember 2012, 07:00 Uhr

Here is a reiteration of what rlaely makes Dependency Injection (DI) worthwhile. First of all IoC and DI is not the same thing. DI is one type of IoC (read ch. 4 of Pro Spring ).Example:You have component CC, which needs to use a service of type SS. Of course, CC should ideally not need knowledge about any implementations of SS. One implementation of SS is called SImp. SImp can of course not have knowledge about where it should be used, so no references to CC within SImp.Now: How can we make CC use SImp? Well, in my opinion DI handles this very elegantly:It stands outside of both CC and SImp and creates (injects) the link (dependency) between the two.