Michael Long
Sep 14, 2024

--

Need to get past the name, as Singletons are useful critters to have around.

That said, we tend to confuse the Singleton pattern (there can be only one), with "singletons" that are little more than globally accessed variables.

I can have a Singleton-based system, like, say, Analytics, in which one and only one instance should ever be initialized and exist.

And the reference to that instance could be accessible through a global or static variable visible throughout the code base (bad)... or injected wherever it's needed via DI (good).

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (1)