Hermes Wiki

Singleton

Ensures a class has exactly one instance, globally accessible — one of the most overused and most misused GoF patterns.

Why we need this / what value this brings

Guarantees exactly one instance exists — useful for genuinely global, expensive-to-create resources like a DB connection pool.

When to use this

Sparingly — only for something that must truly be singular and global (a connection pool), not as a default way to avoid passing dependencies around.

How to use or implement this

In most modern frameworks this is better achieved via dependency injection (a container-managed single instance) than a hand-rolled singleton class, which is harder to test.

Research questions

  • Global mutable state (which is what a singleton is) makes testing harder — where would dependency injection be the better alternative to a Localz singleton?

Empty folder — drop notes, links, and findings here as you research.

Hermes Wiki