Skip to Content.
Sympa Menu

patterns-discussion - RE: [patterns-discussion] Erich Gamma quote

patterns-discussion AT lists.cs.illinois.edu

Subject: General talk about software patterns

List archive

RE: [patterns-discussion] Erich Gamma quote


Chronological Thread 
  • From: "Sriram Gopalan" <Sriram.Gopalan AT agile.com>
  • To: "Arno Haase" <Arno.Haase AT Haase-Consulting.com>, "Patterns-Discussion" <patterns-discussion AT cs.uiuc.edu>
  • Subject: RE: [patterns-discussion] Erich Gamma quote
  • Date: Thu, 4 Dec 2003 12:33:24 -0800
  • List-archive: <http://mail.cs.uiuc.edu/pipermail/patterns-discussion/>
  • List-id: General talk about software patterns <patterns-discussion.cs.uiuc.edu>

I am not sure about why (or whether) Gamma said that, but the singleton
pattern, as is it commonly used, does offend some OO purists. The main
complaint is that the singleton class does two distinct, unrelated things -
(1) at the class level, control the number of instances and (2) at the
instance level, whatever it is supposed to do (like control a shared
resource, for example).

With the presence of namespaces (like in C++ and Java packages), there is no
reason why these two functionalities cannot be put into two different
classes that are exclusively present in the same namespace.

In Java world, this means that there would a public InstanceController class
and a package level SingletonInstance class in the same package, say,
mypackage.singleton. There would be no other classes in that package. The
clients would only deal with the InstanceController class to get hold of
SingleInstance instances.

This way, if the requirements for one of these functionalities changes, we
can modify and test one class without affecting the other.

Also, since it the most "popular" pattern, it is also the most widely misused
one. Any software project today is filled with singletons, simply
because it is (1) easy to do and (2) "patterns are cool and good". People
don't seem to understand the forces that give rise to the need for this
pattern (or any pattern for that matter).

reg,
Sriram

-----Original Message-----
From: Arno Haase
[mailto:Arno.Haase AT Haase-Consulting.com]
Sent: Thursday, December 04, 2003 10:19 AM
To: Patterns-Discussion
Subject: [patterns-discussion] Erich Gamma quote


Hi,

I heard that Erich Gamma once said in an interview that given the chance
to make some change to the GOF book, he would remove the Singleton pattern.

Do any of you have a reference for that (or rather, for what he actually
said, because it likely got distorted in the retelling)?

Thanks a lot in advance

- Arno

_______________________________________________
patterns-discussion mailing list
patterns-discussion AT cs.uiuc.edu
http://mail.cs.uiuc.edu/mailman/listinfo/patterns-discussion






Archive powered by MHonArc 2.6.16.

Top of Page