Singleton Pattern Term As Coined

I think that the community should just refactor SingletonPattern. That entry should respect the term's heritage and common usage at large. This entry could then be removed.


== Preamble ==

"The traditional technique for the analysis of language is the examination of printed texts -- an ancient tradition still hallowed in lexicography"

 From "Meaning and Grammar" by Patrick Hanks
 Collins English Dictionary
 William Collins and Sons, 1980
 ISBN  000433080-3 

Naturally, language is a living thing. Vernacular speech, in particular, is very fluid. The word 'bad' can actually mean its exact opposite in the right context.

For technical terms, such as the one under discussion (SingletonPattern), one would like to be a little more precise than vernacular speech. One must respect actual usage if it overwhelms the canonical source of the term. However, if there is any real controversy, I would give more weight to the published source rather than the (presumed) meaning from usage.

== What is the Singleton Pattern? ==

There is a book called "Design Patterns" and it appears to be the canonical source for the definition of SingletonPattern. The 'beef' of that definition is one single sentence under the heading 'Intent' and it is as follows:

Ensure a class only has one instance, and provide a global point of access to it. [P. 127 in my 1996 edition]

I have been lectured a couple of times on this wiki that the above is NOT the meaning at all. I would suggest that for the sake of clarity (and the sanity of older programmers) that the original definition be re-instated (if it indeed were being used differently). The term already had a meaning and that meaning and purpose were crystal clear. The fact that it was a bad idea should not cause its meaning to morph into something else. A new idea should be given a new name.

Here's a link: http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29 Here is a quote from that link:

"Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994 (Gamma et al). That same year, the first Pattern Languages of Programs conference was held and the following year, the Portland Pattern Repository was set up for documentation of design patterns. "

Note the following: this wiki POST-DATES the book that popularized the term we are talking about. In the book that presumably influenced this wiki, the definition of a Singleton is simple and unambiguous.

The above is the only sentence in that paragraph and it is a direct quote. It is (essentially) from that definition that the notion of 'global' is coming and if you have somehow managed to reconstruct its meaning to remove the bitter flavor of 'global', you have failed to bring it into common usage as far as I can tell. The links at ForThisPurposeSingletonsAreGlobals attest to that.

And you'll be lectured again. Nobody said that the above "is not the meaning at all", that's your spin on the "lecture" you received, which either means that the lecturer was bad or that you weren't paying attention. The above is slightly inaccurate in that it suffers from overprecision. The "global point of access" part is strictly unnecessary, but it's understandable given the historical context of the GoF book that was written with languages like Smalltalk and C++ in mind, so at the time it looked like "global point of access was justified", (especially in Smalltalk). A decade and a dozen popular languages later, it is clear that the SingletonPattern is also deployed in contexts where the scope of the access function is not necessarily global. So the definition on this wiki turns out to be more accurate. -- CostinCozianu

---

Here is the exact quote from ForThisPurposeSingletonsAreGlobals: The "global point of access" part is simply wrong.

You are at liberty to play with words and argue all you like. It will not impact the many links (and thousands more like it) referenced in the page above. It will also not affect the way that terms are actually defined. The very fact that even you choose to 'abjure, curse, and detest the error' of the original definition (sort of backwards, but http://cscs.umich.edu/~crshalizi/White/astronomy/victory-church.html) should be proof that the pattern should simply revert to its 'dictionary meaning' and then be deprecated.

BTW -- You will succeed in driving me away from this wiki. I am simply going to set the record straight and move on. You can then happily 'refactor' all my commentary back to your lovely self-defined, sand-shifting, delusional prose as I found it. Here's the actual quote from the link above, lest it go dead:

I, Galileo, being in my seventieth year, being a prisoner and on my knees, and before your Eminences, having before my eyes the Holy Gospel, which I touch with my hands, abjure, curse, and detest the error and the heresy of the movement of the earth.

You are, in essence, saying something as counter-factual as 'the sun revolves around the earth'. You may say it until doomsday. You may even convince the mob to completely erase history here on this wiki. I feel you will have less success removing the book from publication or shutting down the 25,000 odd references to 'Singleton Pattern' and 'global' that exist on the web. Heck, you might even do it. You will still not succeed in resurrecting the Singleton Pattern itself. It hard-codes cardinality and breaks scope. It will kill itself in the wild anyway. I was just trying to save a few earnest beginners a little grief.

== The lessons of history ==

I would simply love to be the one to coin the new term for the replacement to this pattern. However, anything resembling this pattern of necessity suffers the same ills as the original. MultitonPattern, for instance, would ostensibly cure the cardinality problem. However, were it to carry the baggage of the scoping problems, it would be little better. I would suggest that there is really no reasonable replacement for SingletonPattern that maintains its erroneous conflation of (probably near-sighted and presumptuous) specific cardinality and 'scope busting'. Note that building a class with specific cardinality like this is analogous to what we used to call 'hard coding' in the olden days. The arguments in favor of hard coding were just as fierce as the one under discussion. Who amongst us has not (maybe we though temporarily) hard-coded something? It is the sin I am attacking here, not the sinner.

Nota Bene: "Those who cannot remember the past are condemned to repeat it" (http://en.wikipedia.org/wiki/George_Santayana). Note also the very apt title of the book from which that quote was taken: "Reason in Common Sense". In case the point is lost here, the GOF book ADDS to the tradition of programming. It is not the tradition itself. That book is no bible of programming and should hardly be taken as such. There is a very rich tradition of programming and its underlying principles stretching back from before a time when even I was around.

[GuyWhoReopenedTheSingletonCanOfWorms]


EditText of this page (last edited March 3, 2010) or FindPage with title or text search