8 Object lifetime

In this chapter

  • Managing Dependency Lifetime
  • Working with disposable Dependencies
  • Using Singleton, Transient, and Scoped Lifestyles
  • Preventing or fixing bad Lifestyle choices

The passing of time has a profound effect on most food and drink, but the consequences vary. Personally, we find 12-month-old Gruyère more interesting than 6-month-old Gruyère, but Mark prefers his asparagus fresher than either of those.1  In many cases, it’s easy to assess the proper age of an item; but in certain cases, doing so becomes complex. This is most notable when it comes to wine (see figure 8.1).

1  Steven, however, doesn’t like asparagus at any age, but does prefer his whiskey of older age.

Wines tend to get better with age — until they suddenly ...

Get Dependency Injection Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.