Book review: Dependency Injection by Dhanji Prasanna

1 minute read

Over the last few days, I have been reading Dependency Injection by Dhanji Prasanna published by Manning. I must admit, this is a much easier task than writing Hibernate Search in Action ;)

Summary first: very easy to read, a gold mine of knowledge and tips on a subject that is essential to the life of today's Java developers. Go buy it and keep it around your desk.

Let's quickly talk about the book structure. The book walks you gently through the DI (Dependency Injection) subject:

  • why do you need DI, what does it solves concretely in application developments
  • what is injection, what are the main concepts
  • using DI to improve application modularity
  • object scoping and how to approach that with DI solutions
  • best practices learnt with tears and blood
  • and a small concrete application showing how to use Guice as your DI container

If you are a beginner, this book will explain to you how and why using DI. If you are an expert and use DI on a daily basis, this book will help you rethink what you have taken for granted in DI-land and learn a handful of new tricks and design patterns.

I consider DI and the notion of scope (aka context) to be an essential knowledge to any Java developers. This will become even more pressing with the soon arrival of JSR-330 (Dependency Injection for Java) and JSR-299 (Context and Dependency Injection for the EE platform aka Web Beans) and their inclusion in Java EE 6.

Just like you had to learn polymorphism, you need to learn DI and context management as this is an essential tool for proper component design and application modularization.

The only gotcha is that this book comes right before the finalization of the two JSRs and hence does not cover them. Don't be too afraid though, all the core concepts covered by these specifications are thoroughly explained in this book. The problem / solution approach used by Dhanji will perfectly complement your knowledge of the DI JSRs.

My advice is to keep this book on your desk when you develop (next to Hibernate Search in Action mine of course ;) ), you will save yourself the burden of learning the best design approaches the hard way.

Tags: ,

Updated:

Comments