The First Guice Review
Eric discovered that Guice really does result in less code:
At the end of the day, I compared my [Guice] modules — written in Java — to my Spring XML files. The modules are significantly smaller and easier to read. Then I realized about 3/4 of the code in my modules was unnecessary, so I stripped it out. They were reduced to just a few lines of code each.
Eric noticed another feature which you can't really appreciate until you actually use Guice:
The error messages are exceptionally good when things go wrong. You can tell they put a lot of effort into this, and this is HUGE. Every single framework should learn this lesson: cryptic error messages are a major drain on developer productivity, and we really appreciate tools like Guice.
We invested countless hours into making Guice's error messages as helpful as possible. We use plain English. We print line numbers (in such a way that IDEs automatically link to source code). We suggest likely causes and even fixes.
In the end, it sounds like Eric is sold:
I successfully converted the client, but ran out of time for the server piece. Based on what I did accomplish, however, I definitely plan to finish the job as soon as possible.
We'll look forward to the rest.
Disclosure: I used to consult for OCI, too, but didn't work with Eric. Many consulting firms abuse their brand to trick clients into paying top dollar for off-the-street programmers with no real qualifications. If you're looking for a consulting/training firm with real top talent, I highly recommend OCI. I'm not just saying that because Eric wrote a favorable review either. :)
6 Comments:
Spring (or more generally, and IoC) configuration can indeed be bloated.
To make matters worse, the price is higher when you compose your system out of lots of small classes!
On my project, we've extended the Spring bean factory to reduce a lot of the noise. Instead of just autowiring beans together, we actually auto-define beans based on our naming convention.
When our bean factory needs an implementation of the interface SomeService and none is available in the explicitly defined beans, it looks for a class DefaultSomeService and creates a bean in the singleton scope.
In practice, this reduced our wiring XML files by around 75%, leaving the interesting wiring: beans with injected configuration, aspects, and interfaces with various implementations.
I haven't had a chance to play with Guice yet, but it would be nice to avoid repetivive calls to:
bind(Service.class)
.to(ServiceImpl.class)
.in(Scopes.SINGLETON);
Jason, Guice supports your needs, and it would still be able to verify your configuration at startup.
First off Bob, I wanted to say good job on Guice. I also recently wrote an IoC container that's 100% Annotation based. I didn't design it to compete with Guice, since I wrote it before Guice was around. My Annotation Container is very fast and light weight. The purpose behind AnnoJection (My IoC container) was to show how AnnoContainer (Another project I recently created.) makes working with Annotations very easy. Using AnnoContainer, you can decorate an existing Pojo and transform it into what I call a “Annotation Processor”. You don't have to implement any interface and like Guice, the method signatures can be anything. AnnoContainer inspects the methods to see how it should invoke it. AnnoContainer is around 25 – 35 kbs big and can process 100,000 iterations on a class that has 4 fields, 4 methods, class level annotation, package annotation and 4 method parameters decorated in 1 second. If you implement the Processor interface, it'll bring it down to around 500 milliseconds.
Hey, long time no see on Efnet :) -MeLearnin
Best Regards,
Richard L. Burton III
Hi Bob,
thanks for the new container. I still think dynaop is the best AOP for Java there is. I'm starting a new OSS project and look into Guice for the IoC container, I like your thinkign style (and thought for years Springs XML is bloated especially compared to dynaop).
keep up the good work
-stephan
Bob: Thanks for aid in the lonely battle against ugly Spring-bloat. Best to you and yours.
- Tim Williams
Tim! Send me an email if you see this.
Post a Comment
<< Home