Summary
In this chapter, I have explored four basic creational patterns.
The first one was singleton, a pattern used when we need exactly one instance of a class. The chapter looked at a few bad and a few good implementations and explored alternatives.
After that, I switched to the DI pattern, which can sometimes be used to replace a singleton. As DI is incredibly large area, the chapter has focused on basics and explored different injection mechanisms.
The third pattern in this chapter was lazy initialization. The mechanism behind the lazy initialization (the test, create, use idiom) is so simple that most of the time we don't think about this concept as a pattern. It can still be tricky to implement this pattern correctly, and I have pointed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access