Chapter 3. DI Containers



  • XML configuration
  • Code as configuration

When I was a kid, my mother and I would occasionally make ice cream. This didn’t happen too often, because it required a lot of work and it was hard to get right. In case you’ve never tried making ice cream, figure 3.1 illustrates the process.

Figure 3.1. Making ice cream is an arduous process, with plenty of opportunities for error.

Real ice cream is based on a crème anglaise, which is a light custard made from sugar, egg yolks, and milk or cream. If heated too much, this mixture will curdle. Even if you manage to avoid this, the next phase presents more problems. Left alone in the freezer, the cream mixture will crystallize, so you have to stir it at regular intervals until it becomes so stiff that this is no longer possible. Only then will you have a good, homemade ice cream.

Although this is a slow and labor-intensive process, if you want to and you have the necessary ingredients and equipment, you can use the technique I’ve outlined to make ice cream.

3.1. Introducing DI Containers

3.2. Configuring DI Containers

3.3. DI Container patterns

3.4. DI Container landscape

3.5. Summary