Jolt Awards: The Best Books

Mark Seeman's Dependency Injection in .NET is aimed at the large number of developers who have never used dependency injection (DI) or who aren't comfortable enough to employ it routinely. The first two chapters provide a brilliant and remarkably readable explanation of DI and illustrate through well-chosen examples where and how DI makes sense. In this early going, Seeman avoids using a specific framework, which in other books forces the reader to learn particular semantics in order to simply understand the pattern. His explanation of inversion of control (IoC) is conceptual and clear, illustrating the benefits of loose coupling and simpler coding. He then pushes on into a catalog of patterns that rely on DI. Along the way, Seeman also discusses anti-patterns that undercut the benefits DI can deliver. To remedy the latter and to show how DI is best done, the author also expounds on DI refactoring, which shows how well this model can work and how it improves readability, maintainability, and testability of code.

The code is in C#, which means that it will be readable to developers who know Java, C++, or other languages with a C-based syntax. However, once the basics have been explained and the patterns and anti-patterns explored, the book dives into DI frameworks for .NET, notably StructureMap, Castle Windsor, Ninject, and Unity. It also explains integration of DI with Microsoft ASP.NET.

There are certainly other books on the market that cover DI and IoC, but none of them explain the principles and the design of these patterns as well or as thoroughly as this book. It's the definitive guide to DI and the first place architects and implementers should turn for a truly deep and complete understanding of the pattern  regardless of whether .NET is part of their toolkit.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.