Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is nothing wrong with this code and you can still use it with Dependency Injection frameworks like Spring and Guice. </p> <p>Many developers see Spring's XML configuration file as an advantage over wiring dependencies within code as you can switch implementations without needing a compilation step. This benefit actually is realized in situations where you already have several implementations compiled in your class path and you want to choose the implementation at deployment time. You can imagine a situation where a component is provided by a third party after deployment. Similarly there can be a case when you want to ship additional implementations as a patch after deployment.</p> <p>But not all DI frameworks use XML configuration. Google Guice for example have Modules written as Java classes that must be compiled like any other java class.</p> <p>So what is the advantage of DI if you even need a compilation step? This takes us back to your original question. I can see following advantages:</p> <ol> <li>Standard approach to DI throughout application.</li> <li>Configuration neatly separated out from other logic. </li> <li>Ability to inject proxies. Spring for example allows you to do declarative Transaction handling by injecting proxies instead of your implementation</li> <li>Easier re-use of configuration logic. When you use DI extensively, you will see a complex tree of dependencies evolving over time. Managing it without a clearly separated out configuration layer and framework support can be a nightmare. DI frameworks make it easy to re-use configuration logic through inheritance and other means.</li> </ol>
    singulars
    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. 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.
    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