on 15 November 2009
Dependency Injection by Dhanji Prasanna is essential reading for anyone wanting to understand how to organise and structure modern Java codebases using Dependency Injection (DI) techniques.
Now that JSR-330 (Dependency Injection for Java) is part of the JDK, DI will become an important design technique for modularising and organising code, one that isn't taught in standard Java or OO texts. Up to now coverage on DI has been limited to online documentation, blog posts about testing, and sections here and there in books, so it's good to see sound engineering practice captured in one place. Dependency Injection covers two frameworks in detail - Spring and Guice and the coverage is balanced. As the authors are Guice contributors, this is to their credit - an easy out would be to write a book on just Guice.
I like that the book explains the principles behind DI and not just how certain frameworks work. I didn't think DI could justify a whole book and expected a lot of filler, but the title doesn't do justice to the material covered. Dependency Injection also has a wealth of practices and techniques for organising and programing Java systems. I don't think there's another book in print that provides the kind of information you can find here. Most DI material focuses on testing, which is important but just one aspect of why DI matters - this book goes beyond that and covers practical modular software architecture in some detail. Highly recommended.