Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may want to include Spring in your list of Dependency Injection frameworks you are considering. Here are some answers to your questions:</p> <h2>Coupling to the framework</h2> <p><strong>Pico</strong> - Pico tends to discourage setter injection but other than that, your classes don't need to know about Pico. It's only the wiring that needs to know (true for all DI frameworks).</p> <p><strong>Guice</strong> - Guice now supports the standard <a href="http://code.google.com/p/google-guice/wiki/JSR330" rel="noreferrer">JSR 330</a> annotations, so you do not need Guice specific annotations in your code anymore. Spring also supports these standard annotations. The argument that the Guice guys use is that without a Guice annotation processor running, these shouldn't have an impact if you decide to use a different framework.</p> <p><strong>Spring</strong> - Spring aims to allow you to avoid any mention of the Spring framework in your code. Because they do have a lot of other helpers / utilities etc. the temptation is pretty strong to depend on Spring code, though.</p> <h2>Performance</h2> <p><strong>Pico</strong> - I'm not too familiar with the speed characteristics of Pico</p> <p><strong>Guice</strong> - Guice was designed to be fast and the comparison mentioned in the reference has some numbers. Certainly if speed is a primary consideration either using Guice or wiring by hand should be considered</p> <p><strong>Spring</strong> - Spring can be slow. There has been work to make it faster and using the JavaConfig library should speed things up.</p> <h2>Ease of use</h2> <p><strong>Pico</strong> - Simple to configure. Pico can make some autowire decisions for you. Not clear how it scales to very large projects.</p> <p><strong>Guice</strong> - Simple to configure, you just add annotations and inherit from AbstractModule to bind things together. Scales well to large projects as configuration is kept to a minimum.</p> <p><strong>Spring</strong> - Relatively easy to configure but most examples use Spring XML as the method for configuration. Spring XML files can become very large and complex over time and take time to load. Consider using a mix of Spring and hand cranked Dependency Injection to overcome this.</p> <h2>Community Size</h2> <p><strong>Pico</strong> - Small</p> <p><strong>Guice</strong> - Medium</p> <p><strong>Spring</strong> - Large</p> <h2>Experience</h2> <p><strong>Pico</strong> - I haven't had much experience with Pico but it is not a widely used framework so it will be harder finding resources.</p> <p><strong>Guice</strong> - Guice is a popular framework and its focus on speed is welcome when you've got a large project that you're restarting a lot in development. I have a concern about the distributed nature of the configuration i.e. it's not easy to see how our whole application is put together. It's a bit like AOP in this respect.</p> <p><strong>Spring</strong> - Spring is usually my default choice. That said, the XML can become cumbersome and the resulting slowdown annoying. I often end up using a combination of hand crafted Dependency Injection and Spring. When you actually need XML based configuration, Spring XML is quite good. Spring also put a lot of effort into making other frameworks more Dependency Injection friendly which can be useful because they often use best practice when doing so (JMS, ORM, OXM, MVC etc.).</p> <h2>References</h2> <ul> <li><a href="http://picocontainer.com/" rel="noreferrer">Pico</a></li> <li><a href="http://code.google.com/p/google-guice/" rel="noreferrer">Guice</a></li> <li><a href="http://www.springsource.org/" rel="noreferrer">Spring</a></li> <li><a href="http://www.christianschenk.org/blog/comparison-between-guice-picocontainer-and-spring/" rel="noreferrer">Spring / Guice / Pico comparison</a> </li> <li><a href="http://www.javalobby.org/articles/guice-vs-spring/" rel="noreferrer">Another Spring / Guice performance comparison</a></li> </ul>
 

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