Comments on: A quick look at Guice A dependency injection framework by Google https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/ Friends of Oracle and Java Fri, 06 Mar 2015 01:45:01 +0000 hourly 1 http://wordpress.org/?v=4.1.1 By: Bob Lee https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/#comment-4635 Sat, 26 May 2007 18:35:35 +0000 http://technology.amis.nl/blog/?p=2031#comment-4635 Thanks for the feedback.

First, the Guice manual uses “@Blue” not “@BlueService”. You typically have a small set of reusable annotations which you can share across multiple bindings; you don’t create a new annotation for each binding. It’s not like Spring where each name must be unique. Also, from my experience, you only use annotations about 5% of the time (if that); these aren’t equivalent to Spring’s bean names which you must always use.

Second, Spring actually spreads your configuration out more and requires more of it. With Spring, you have the configuration for Service, the XML mapping Service to Client, and Client itself–3 places. With Guice, you just have the configuration for Service and Client itself–two places.

I agree that there appears to be little benefit from using Guice in this small example (I point this out in the manual before we even start this example). The benefits from Guice kick in when you use Service again from another object. With Spring, you would need external XML to wire Service to each new object (autowiring is not an option). With Guice, you just put @Inject anywhere you need Service.

If maintainability is a high priority (we spend a lot more time reading code than we do writing it), then I would try Guice–that’s why we built it. For more information, check out our Guice/Spring comparison: http://code.google.com/p/google-guice/wiki/SpringComparison

]]>
By: Jeroen van Wilgenburg https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/#comment-4634 Mon, 21 May 2007 12:58:19 +0000 http://technology.amis.nl/blog/?p=2031#comment-4634 I think he just wanted something else. When you’re working on a Spring project for months something completely different can be quite refreshing.

]]>
By: erik https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/#comment-4633 Mon, 21 May 2007 12:23:15 +0000 http://technology.amis.nl/blog/?p=2031#comment-4633 You started your blog with the remark that your old collegue is “tired of Spring”. It made me curious to read why….. Was your collegue just ready for a new challenge or did he mention an argument against this framework? I agree with your arguments that Guice DI does not offer any special benefits, as you described it.

]]>
By: Jeroen van Wilgenburg https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/#comment-4632 Mon, 21 May 2007 09:59:36 +0000 http://technology.amis.nl/blog/?p=2031#comment-4632 While I was writing the blog entry yesterday I thought I saw something like the Guice config in Spring, but couldn’t find it on the Spring site.
Thanks for pointing me to that site, it looks promising and I totally forgot about it, but I have to read more about JavaConfig to see how it compares to Guice.

]]>
By: Mikael Gueck https://technology.amis.nl/2007/05/20/a-quick-look-at-guice-a-dependency-injection-framework-by-google/#comment-4631 Sun, 20 May 2007 23:06:05 +0000 http://technology.amis.nl/blog/?p=2031#comment-4631 How would it look using the Spring Java annotation based configuration?

http://static.springframework.org/spring-javaconfig/docs/1.0-m2a/reference/html/

]]>