Author: Dhanji Prasanna
Publisher: Manning, 2009
Aimed at: Java developers
Pros: A clear practical account of a difficult topic
Cons: Later chapters tend to be repetitive
Reviewed by: Mike James
It seems that dependency injection is all the rage at the moment - but can you find a clear account of what it's all about? This book satisfies this request in most respects and as such it's a worthwhile read even if you don't plan to use DI any time in the near future. Of course the book is all about Java technologies and this just emphasises the fact that other languages, and .NET in particular, just haven't kept up with these ideas.
The book starts off with a very readable account of dependency and how to manage it. Moving from getter/setter, constructor, factory objects and finally to full dependency injection as ways of coping. The argument is persuasive and the examples are short enough to follow. The only problem is that there is quite a lot of repetition in the following chapters which seem to repeat the argument for why we need DI made in the first chapter.
The book is based on the use of Spring and Google Guice - pronounced Juice and we have to forgive Google's obsession with G's. This isn't a problem but many of the early examples are explained using Spring and then using Guice or some other framework to contrast different approaches to the problem. This is a good idea but not so early in the book when the beginner might still be struggling to with the basic ideas. Also the repetition tends to undermine your understanding as you ask yourself if this is something new or a restatement of what you were told and thought you understood.
Despite these criticisms this is the best book so far on dependency injection and it is worth it for the early chapters alone which do succeed in getting the ideas across to a complete beginner - as long as you are comfortable with Java and fairly sophisticated about object technologies. So until something better comes along if you want to join in the conversations about dependency injection you probably need to read this book.