Foreword

My first experience with Dependency Injection was almost 10 years ago. I was working at an ISV (independent software vendor) as an architect on an enterprise framework building LOB (line-of-business) applications. In those days, it seemed like all my friends in the industry were building similar frameworks. The framework supported various layers across n-tier applications addressing data access, business, and UI concerns. The product-supported business objects could be persisted across multiple databases and represented in multiple UIs; the challenge was finding a way to build the system to make it extensible and maintainable. We found our answer by wading into the waters of Dependency Injection. Using a DI approach, we clearly defined contracts for the layers, allowing us to more easily test the layers as well as to swap their implementations without breaking the code.

Mark talks quite a bit in this book about “poor man’s DI” and this is exactly what we were doing. In those days, we didn’t have DI containers at our disposal. We also didn’t have the type of guidance you’ll find in this book. As a result, we made a lot of mistakes—mistakes you won’t have to make.

In the past four years, I’ve personally worked with hundreds of customers and I’m aware of thousands that have found success using the techniques described in this book.

It all starts with patterns.

DI containers are just tools. The tools are only useful if you’re building systems that incorporate the patterns that the tools are addressing. They aren’t the solution to every problem. Ideally, you need to first learn what Dependency Injection is, what kinds of problems it solves, and what the patterns are for using it. Then you can look at the various tools as aids in applying those patterns.

This book will help you with all of the above. The early chapters present an overview of the general problems that occur when software is tightly coupled. The book then discusses ways we can apply various techniques, both simple and advanced, to address those problems. Along the way, the book classifies various patterns and identifies when they are most appropriate for specific situations. In the second half, the book presents a comprehensive overview of the most common DI containers/frameworks in .NET and explains how to use them to apply different techniques.

With this book, you will benefit from the knowledge of someone who has many years of real-world experience in applying these techniques. This is a real treat; often, those who start using DI quickly find themselves lost in a sea of confusion. This book addresses any potential misunderstanding, starting with basic questions like, “Where should I put my IoC?” or “Should I expose my container?” Mark covers these questions and many more.

Throughout the book, Mark not only describes the techniques but really goes into depth explaining when you should—and, more importantly—shouldn’t use them. When he describes a problem, he uses realistic examples to keep the big picture in focus.

If you are new to IoC, I believe you’ll find Dependency Injection in .NET to be a great resource for learning. Even if you have extensive experience with IoC, you’ll still benefit from the painstaking work Mark has done to classify various patterns and create a taxonomy for IoC. I also think that you will find his comparisons with other IoC containers beneficial.

Regardless of your level of experience, I wish you success with this book.

GLENN BLOCK

SENIOR PROGRAM MANAGER

MICROSOFT

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.47.218