Polski

Creational patterns

Singleton

Exactly one instance with a shared access point – use sparingly, it is global state in disguise.

Article

Singleton – one instance, and the reasons to hand it to a DI container

Singleton guarantees that a class has exactly one instance available to the whole application. We show thread-safe implementations in five languages and explain why today it is usually better to register the object as a singleton in a DI container.

Related articles

Around the topic

In this group: Creational patterns