I really enjoy reading a book that can show me a new approach to what I have already considered well understood and barely surprising. I'm currently learning Java EE 6 and has begun my journey to the area of the Contexts and Dependency Injection for the Java EE platform and the Java EE 6 Managed Beans specifications. I can't really explain why I picked up these specs, but they made me wonder about the current state of dependency injection containers. It looks to me that JEE6 application servers are not that much explored and quite often loaded with applications that are in turn managed by Spring Framework and its kind of kitchen-sink stack. Many developers put their faith in Spring Framework and look no further. It is as though a sole Java EE application server were less important and the only trusted solution were Spring Framework itself which eventually became the Java EE application server. Too bad.
The book "Dependency Injection, Design patterns using Spring and Guice" by Dhanji R. Prasanna from Manning has showed me that there's a hope for such a thinking and Guice comes to our rescue - to those passionate enterprise Java developers who once thought a Java EE application server has been too much burden on their shoulders and Spring Framework + Apache Tomcat combo has been enough. My take on it is that Spring Framework requires now so much time to understand how it works that one can hardly find a few spare cycles to look for and afterwards evaluate alternatives. The initial attempts of Spring Framework to lend a helping hand to us and ease development of Java enterprise applications had certainly been achieved, no doubt about that, period, but the development of Spring Framework didn't stop that led to create another 100-pound gorilla. It's now something bigger than a mere DI container and as much complicated as its origins once were. With that gut feelings, one day I noticed this book begging for my reading and without much excitement yet wondering what I could learn about dependency injection I grabbed it and started the reading. Before it I had no clue whatsoever about Guice, and noticed the subtitle right at the moment I write the first sentence of the review.
The book is written by "a Google software engineer who works on Google Wave and represents Google on several Java expert groups. He contributes to Guice" (from the ABOUT THE AUTHOR section of the book's home page at Manning). I found it out once I'd finished reading the book and spent quite a few moments to think whether or not there were places where I could've figured out the origins of the author myself earlier. I can honestly say that if there had been such I could have spotted none. Be rest assured, the author handled the subject of dependency injection and supportive design patterns like adapter, provider and proxy with a great care and covered the way Spring Framework does the DI job as often as Guice (with some coverage of PicoContainer too). The book presented code snippets that were mostly Guice-oriented though, which I found very informatory and valuable. Mind the aim of the book - the concept of dependency injection, and it was not an easy task to do it in detail keeping the fair balance between Spring Framework and Guice (the book would've otherwise been twice long). The topic was described in 11 chapters and the samples ensured the book was by no means boring and served their purpose very well. I think it would have been even better if it'd devoted itself completely to Guice leaving Spring Framework aside for which there're many books available.
As you might've guessed by now, for me the most valuable pages of the book were those with Guice covered. I read them with a great passion and found striking similarities to these two Java EE 6 specifications - CDI and Managed Beans. It was as if I'd been reading the specs again. Having read the book helped me understand them better. Their goal is much clearer now once I realized their origins and what design issues influenced their development. It was in the chapter 2. "Time for injection" when I finally found the answer to the question I was struggling with for some time - "Are annotations a correct way to convey additional configuration?" They certainly are. Coverage of JSR-303 Bean Validation in the chapter 10. "Integration with third-party frameworks" as a case study of a well-designed framework with DI in mind wasn't something exceptional in this book. There were some sentences and an example about CGLib (which I'm about to learn), but I wished it'd been more. The book was filled out with many fine explanations of the entire dependency injection ecosystem, and was a complete no-brainer to find something worthy. With many refreshing angles of looking at dependency injection one can barely be left with a bad taste in mouth.
Not only did the author take a great care to explain the concepts around dependency injection, but the language itself was very professional and with a great sense of humour. I definitely learnt a lot - dependency injection, design patterns around it, Spring Framework and finally Guice as well as a bunch of new words and phrases in English. The reading was worth its time and I'm certainly going to refer to the book's chapters every now and then. In a blink of an eye, "Dependency Injection, Design patterns using Spring and Guice" by Dhanji R. Prasanna from Manning turned me into a Guice passionate. It's not clear if it's Guice itself or the book, but I have no doubts about a DI container when one's requested. The book presented quite a few examples of Guice for web development so you should find it a viable alternative to Spring Framework stack if you run across such a need. It urged me on to try out Guice and its extensions. I've got some ideas for more developments too and whenever designing a solution I'll look back to the book as a definitive source for thought-provoking advices. Thanks Dhanji!
Author(s): Dhanji R. Prasanna
Edition: 1
Publisher: Manning Publications
Year: 2009
Language: English
Commentary: +OCR
Pages: 354