“Google Guice! Google Guice! Google Guice!” *waiting*… *nothing happens*… But… I said it three times. I was expecting something magical, something like my code would compile automagically, dependencies injected, tests created… Hold on a second! That was in another movie… 😉
Enough joking! Have you heard about Google Guice (as you’ve already guessed, it’s pronounced “Juice”)? It claims to be the “next generation” ultra-lightweight dependency injection container. Especially the “ultra-lightweight” bit makes me smile. It sounds like there’s a lightweightness competition and someone is trying hard to impress us :).
Well, I’m going to give it a shot. Whatever comes from Google shouldn’t be taken lightly (even though the technology itself is advertised as ultra-light 😉 ). First of all, I must say that their documentation is pretty poor, especially in terms of sample code. This is one thing that they should definitely improve on. If they want to be compared with Spring Framework, there’s a lot of work to do in terms of documentation. We like lightweight frameworks but we don’t like lightweight documentation (unless we had to write it 🙂 ). We like examples, source code, sample applications… Give us at least a working example!
The main idea is that Guice does support external configuration but it doesn’t force the user to have one. “The end of XML hell” they say. By using annotations, the dependency injection remains closer to the code. I’ve just started to look at it so I’m definitely going to blog about it again but so far I think I prefer the Spring approach. Creating new annotations, having Guice dependency all over my code, using @ImplementedBy don’t really appeal to me at first glance. However, as I’ve already mentioned, I haven’t gone through a real example. I’ll have a better appreciation when I get my hands dirty.
To be continued…
– Yagiz Erkan –