I hear this word all the time from our developers. But I never knew what it meant. I am by no means a well educated technologist, below a certain layer I just don’t understand stuff, it’s too granular, I don’t touch it enough, for which ever of the many reasons. But I’m curious. Today I made a point to find that meaning. Like learning a foreign language, if you’re curious and you keep hearing something, it’s only a matter of time before you have to know. I think that’s how we learned our mother tongue. Repetition + curiosity. It’s the minds way of deciding to cache information for ongoing short term availability.
A “Singleton” can refer to a lot of things. In mathematics, or patterns, in field theory. For me it’s the singleton variable as it’s used in software programming that is important. So here are some definitions I found: as defined in Wikipedia: it is “a variable in computer programming that is referred to only once”. Not so explanatory…
More results found this paper which goes deeper than wikipedia; though less specific, it describes it as a set with only one member, but goes on to speak of world order and governance, right not very relevant.
So zooming out again, I found a documentation of ruby where the use of Singleton is described. Wherein it’s explained that the use of it can ensure only one instance of the class is created. And a similar post here describes the same for C# which demonstrates a Singleton pattern which assures only a single instance of the class can be created.
Cutting this down to a 15 minutes or less exposure of the concept, I’d walk away saying a Singleton is used when you need to get something once, and it won’t be used in other instances… feeling lost…. I guess I will have to revisit this later.