Re: Creating framework for singleton pattern?
From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 10/22/04
- Next message: Peter Huang: "RE: Run Microsoft Access Module in VS.NET C#"
- Previous message: Kevin Yu [MSFT]: "RE: ToolTip stops working after I dismiss the window once"
- In reply to: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Reply: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 22 Oct 2004 06:52:51 GMT
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:%2381UXIvtEHA.3572@tk2msftngp13.phx.gbl...
>
> "Nick Malik" <nickmalik@hotmail.nospam.com> wrote in message
> news:rRudd.398781$mD.63412@attbi_s02...
> >I respectfully disagree, Daniel.
> >
> > The Wiki page that I linked is one of hundreds of pages that call into
> > question the usefulness, in the long run, of the Singleton pattern.
> >
> Perhaps it is, but its probably among the worst. That page is little more
> than semi-technical rambling by people who may or may not know what they
are
> talking about.
All of us are in the category of people who "may or may not know what they
are talking about."
The wiki page has a long quote from Kent Beck, creator of Extreme
Programming, discussing a major design issue that he refactored out simply
by removing a badly used Singleton. Realize that the C2 wiki is, first and
foremost, a discussion space. You are going to see opinion when you go
there.
>
> No one argument is terribly convincing, no one argument is well formed,
ane
> no one argument covers all the bases. That page is as much scare tactics
as
> anything else.
>
> Contrast it with the linked GLobalVariablesAreBad article, I thought that
> one was conisderably better.
>
OK... here's a better article:
"Why Singletons are Evil"
http://weblogs.asp.net/scottdensmore/archive/2004/05/25/140827.aspx
or this one
"Perils of the Singleton"
http://www.softwarereality.com/design/singleton.jsp
How about
"Friends don't let friends write singletons"
http://members.capmac.org/~orb/blog.cgi/tech/coding/no_singletons.writeback
Here's a list of programming hot-topics, including one titled:
"The Singleton Design Pattern Does More Harm Than Good"
http://www.lisp-p.org/controversy/
> > I believe in "informed consent". That is, if someone is going to
> > encourage me to engage in a risky behavior, they should have
> > the integrity to share the risks with me beforehand.
> > While I don't think it is wise to turn a
> > valuable technical article into an opinion piece, the OO world has
learned
> > that this pattern is being widely misused... (and others as well,
> > including Visitor, apparently). That learning should not be
> > ignored just because it's not "technical" in nature.
> >
>
> No, it should not be. However, it also shouldn't be displayed as fact(or
in
> a way which suggests it is fact) as there is little to no proof provided
> there.
Where's the proof that GOTOs are harmful? Where's the proof that global
variables are harmful? What do you mean by *proof* in this context?
If you actually read some of the information on that is available, on the
web, about Singletons, you will see that the intent was to describe a
"Creational" pattern, while too many people are using it as a "Behavioral"
pattern (e.g. an OO version of a global variable). If global variables are
harmful (and you don't seem opposed to that notion, and if Singletons can be
misused by allowing the creation of global variables in an OO context, then
that misuse should be considered, by reasonable people, to be harmful.
Logic.
> If you start in on this "informed
> consent" of yours in articles like Jon's, I fear you risk either becoming
> biased towards one opinion or the other, or result in destroying the
purpose
> of the article trying to maintain the balance between the two and
effectivly
> swamping out the technical merit.
Give me some credit. A warning is not a slippery slope, denying the reader
of valuable technical content. It is a door to more knowledge that the
reader has the right to walk through, whenever they see fit. Heck... it's
Jon's article, not mine! He's an excellent writer. Do you think he can't
figure out how to strike a balance?
>
> I do not think an informed decision can be made based only on negative
> viewpoints. The wiki, on its own, is not informative, it is simply
> inflammatory.
>
The door is open to anyone who would like to investigate further. I didn't
present the best article to the readers who are not familiar with the
debate, and for that I (clearly) could have done a better job. I hope that
the links above mitigate my mistake.
> > To the contrary, attached to every set of instructions for how to
> > correctly
> > use household cleaner, there is a warning label about keeping it away
from
> > children. We should be willing to put a warning label on patterns as
> > well... especially the ones that get more misuse than others.
> >
>
> *IF* those are actually misused and not just the vendetta of a small
number
> of loud people.
Vendetta? According to dictionary.com, a vendetta is "A bitter, destructive
feud. [Italian, from Latin vindicta, revenge]
Not sure that anyone on the wiki was seeking "revenge" or was "feuding" with
anyone. Considering the fact that the C2 wiki is where many of the modern
discussions of design patterns began, I'm having a hard time imagining these
conversations as being specifically opposed to OO design patterns... they
are merely being honest about the limitations and misuse of one of the most
common patterns.
> There is an implicit lack of proof that Singletons are bad
> and one article mention is not going to achieve that, its just going to
make
> opinion look like fact.
>
As I said, I should have provided a better article link. I hope that I did
a better job this time.
--- Nick Malik
http://weblogs.asp.net/nickmalik
- Next message: Peter Huang: "RE: Run Microsoft Access Module in VS.NET C#"
- Previous message: Kevin Yu [MSFT]: "RE: ToolTip stops working after I dismiss the window once"
- In reply to: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Next in thread: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Reply: Daniel O'Connell [C# MVP]: "Re: Creating framework for singleton pattern?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|