Part 3. DIY DI
In chapter 1, I gave a short outline of the three dimensions of DI: OBJECT COMPOSITION, LIFETIME MANAGEMENT, and INTERCEPTION. In this part of the book, I expand this viewpoint into three distinct chapters. Many DI CONTAINERS have features that directly relate to these dimensions. Some provide features in all three dimensions, whereas others only support some of them.
However, because a DI CONTAINER is an optional tool, I feel that it’s more important to explain the underlying principles and techniques that containers typically use to implement these features. Part 3 examines how you can do-it-yourself instead of using a DI CONTAINER. You can potentially use this information to build your own DI CONTAINER (but please don’t—the world doesn’t need yet another container) or apply DI without using a container at all—this is what we call POOR MAN’S DI. The main purpose of this part of the book, though, is to expose the underlying mechanisms of OBJECT COMPOSITION, LIFETIME MANAGEMENT, and INTERCEPTION without having to use a specific DI CONTAINER. I think that had I used a specific container, it would have been difficult to distinguish general principles from specific API details.