Dependency Injection

Dependency Injection
Authors
Dhanji Prasanna
ISBN
193398855X
Published
28 Aug 2009
Purchase online
amazon.com

Dependency Injection is an in-depth guide to the current best practices for using the Dependency Injection pattern-the key concept in Spring and the rapidly-growing Google Guice. It explores Dependency Injection, sometimes called Inversion of Control, in fine detail with numerous practical examples. Developers will learn to apply important techniques, focusing on their strengths and limitations, with a particular emphasis on pitfalls, corner-cases, and best practices.

Page 2 of 2
  1. Editorial Reviews
  2. Customer Reviews

Customer Reviews

Eelco Hillenius said
Reading Dependency In Action was an eye opener in the sense that it articulated what I instinctively knew, but what never quite crystalized in my mind. Also, there are interesting tips throughout the book about some of the common pitfalls when implementing DI, and even a chapter with tips for framework developers!

I think more people can learn from this book than they realize. In my experience, a lot of people use frameworks like Spring because everyone else does, without really understanding the core problems they solve. This book will give you that background.

I quite enjoyed the quirky funny writing style, though humor is something that is very subjective, so you may or may not be attracted to his writing style.

Kurt A. Zoglmann said
The information contained in this book is great. The author is very knowledgeable and enthusiastic. Don't let me dissuade you from buying this book, the information it contains is very valuable.

I have read several Manning books before and I didn't feel this book met their standards prior to publication. Another 10% of effort and this book would have gone from good to excellent. This is the reason I only give it 3 stars.

I have some issues with this book. First I don't feel that it has been edited tightly enough. Occasionally the informal language used by the author seemed awkward and I found a couple of grammatical errors.

I take issue that not all of the code snip-its are taken from working examples. (Download the sourcecode for corroborating evidence of this.) This is a bad idea given the size and amount of code snip-its. It is hard for the author to ensure there are no mistakes. There is at least one irritating one on pg. 88 in setting up the creation of a DelivererFactory.

And this is the only book that I can recall re-reading a section because I didn't quite follow it the first time through. I think this had to do with how sections of code changed as an idea evolved and how it was presented. It would have been very helpful to have an upfront sentence or three indicating where we are going when ideas evolve. For example, section 3.3.3 could have benefited from this. I found this particularly irritating at times.

Sometimes illustrations were used pointlessly, such as 7.4. Maybe I didn't see the humor in it. This is a dry subject after all.

I didn't like the flow of which dependency injection frameworks were chosen in any given section. Most of the time Guice would be presented first, but that wasn't always the case. There needs to be more consistency in the order of presentation! And for some reason not a peep was mentioned about Guice in section 7.5. Maybe Guice offers nothing in customizing the lifecycle of an object?

I also felt that chapter 4 needed help. I kept asking myself who this chapter benefited. The concepts of good object oriented design and testability take quite a bit of exposition. Books solely dedicated to this area have been written. And yet because of how dependency injection was presented along with it, I felt it muddied the waters in some ways. The information is good, it just needs more editing to make it more focused.

Chapter 11 is pretty useless until Google releases sitebricks. The whole chapter is a small web demonstration that happens to use this library. Who writes an extended example in a book which has a dependency on something not yet released to the public?? Again, Manning should not have let this problem go to press. Yes, the author also wrote sitebricks.. so I can imagine the conversation. "... it will be released a week after we start printing..."

I'd still recommend buying this book since I'm not aware of a better one on the subject of dependency injection.

Emmanuel Bernard said
Over the last few days, I have been reading Dependency Injection by Dhanji Prasanna published by Manning.
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, you will save yourself the burden of learning the best design approaches the hard way.

[...]

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski