Dependency Injection Principles, Practices, and Patterns (英語) ペーパーバック – 2019/3/16
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
Dependency Injection Principles, Practices, and Patterns teaches you to use DI to reduce hard-coded dependencies between application components. You'll start by learning what DI is and what types of applications will benefit from it. Then, you'll work through concrete scenarios using C# and the .NET framework to implement DI in your own projects. As you dive into the thoroughly-explained examples, you'll develop a foundation you can apply to any of the many DI libraries for .NET and .NET Core.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the Technology
Dependency Injection (DI) is a great way to reduce tight coupling between software components. Instead of hard-coding dependencies, such as specifying a database driver, you make those connections through a third party. Central to application frameworks like ASP.NET Core, DI enables you to better manage changes and other complexity in your software.
About the Book
Dependency Injection Principles, Practices, and Patterns is a revised and expanded edition of the bestselling classic Dependency Injection in .NET. It teaches you DI from the ground up, featuring relevant examples, patterns, and anti-patterns for creating loosely coupled, well-structured applications. The well-annotated code and diagrams use C# examples to illustrate principles that work flawlessly with modern object-oriented languages and DI libraries.
- Refactoring existing code into loosely coupled code
- DI techniques that work with statically typed OO languages
- Integration with common .NET frameworks
- Updated examples illustrating DI in .NET Core
About the Reader
For intermediate OO developers.
About the Authors
Mark Seemann is a programmer, software architect, and speaker who has been working with software since 1995, including six years with Microsoft. Steven van Deursen is a seasoned .NET developer and architect, and the author and maintainer of the Simple Injector DI library.
Table of Contents
- The basics of Dependency Injection: What, why, and how
- Writing tightly coupled code
- Writing loosely coupled code
- DI patterns
- DI anti-patterns
- Code smells
- Application composition
- Object lifetime
- Aspect-Oriented Programming by design
- Tool-based Aspect-Oriented Programming
- DI Container introduction
- The Autofac DI Container
- The Simple Injector DI Container
- The Microsoft.Extensions.DependencyInjection DI Container
PART 1 Putting Dependency Injection on the map
PART 2 Catalog
PART 3 Pure DI
PART 4 DI Containers
Mark Seemann is a software architect living in Copenhagen. Previously a developer and architect at Microsoft, Mark is now an independent consultant.
Steven van Deursen is a seasoned .NET developer and architect, and the author and maintainer of the Simple Injector DI library.
Since then, this has become required reading for my software development staff. There are two realizations that informed this.
The first is that there are a LOT of misunderstandings about dependency injection out there, with quite a few otherwise-reliable sources promoting “best practices” that, ultimately, introduce complexity without necessarily solving the underlying problems. When you go down this rabbit hole, and attempt to make sense of conflicting guidance, two names ultimately emerge from—and stand above—the confusion: Mark Seemann and Steven van Deursen. Consistently, they provide comprehensive, deeply-considered, and rational guidance that not only demonstrates a depth of knowledge, but also establishes a framework, vocabulary, and set of heuristics for thinking through dependency injection challenges. Together, they are the authoritative source on the topic, and this book neatly collates hundreds of articles and StackOverflow responses they’ve made on the topic over the last decade. The book will not only answer your questions, but also address real-world challenges you haven’t yet discovered.
The second is that this isn’t actually a book about dependency injection. It is a design patterns book about writing loosely-coupled and maintainable applications. It is true that it frames this primarily in terms of dependency injection—and, thus, the title of the book. But what the authors recognized is that many of the misunderstandings about dependency injection actually represent more fundamental misunderstandings about software design. As such, instead of simply providing guidance on dependency injection, this book carefully lays out the various approaches people take to solve the underlying problem, how those ultimately fail, and then examines the various design patterns that help address them. In doing so, the book ends up offering a surprisingly practical and approachable exploration of common design patterns.
This is one of those books that will, as you read it, inspire you to refactor your past projects, and immediately change how you approach new code. And not (just) because you’ve leaned a new set of tools or even techniques, but because your knowledge and understanding of fundamental software development practices will have matured. Instead of simply prescribing a set of approaches, this will change how you think about the software design and development.
From this perspective, the second edition is a welcome and impressive update. Yes, it overhauls the technical content to accommodate .NET Core, if that happens to be your framework of choice. More importantly, though, it fully embraces the above perspective, and reorganizes the content around design patterns. The new material on aspect-oriented programming and domain events, in particular, is masterfully presented, and really solidifies (SOLIDifies?) its broader relevance. Further, the guidance regarding what patterns (and tools) to use in which situations has continued to improve, and is both clear-headed and actionable.
Indeed, even if you’ve recently read the first edition of the book, the second edition might well be worth picking up simply for chapters 6, 10, 11, and 12, in particular. (Chapters 10 and 11 are entirely new material; Chapters 6 and 12 have been updated considerably.)
[Disclosure: I was a technical reviewer—an independent, unpaid role—for this edition. I have no commercial interest in the book.]