Re: Singleton --- almost
From: Ryan Stewart (zzanNOtozz_at_gSPAMo.com)
Date: 03/09/05
- Next message: Ryan Stewart: "Re: Singleton --- almost"
- Previous message: Bill Tschumy: "Re: what can't you do in swing but in awt?"
- In reply to: John C. Bollinger: "Re: Singleton --- almost"
- Next in thread: Andrew McDonagh: "Re: Singleton --- almost"
- Reply: Andrew McDonagh: "Re: Singleton --- almost"
- Reply: John C. Bollinger: "Re: Singleton --- almost"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 8 Mar 2005 18:16:10 -0600
"John C. Bollinger" <jobollin@indiana.edu> wrote in message
news:d0hpl6$24n$1@rainier.uits.indiana.edu...
> I think Singleton is the single most misused design pattern in the current
> lexicon.
>
> I have at times heard or received comments that a class should be made a
> Singleton because only one instance is needed: THIS IS TOTALLY WRONG. In the
> first place, whether more than one instance might be *needed* is a completely
> different question from whether more than one instance should be *allowed*.
> Secondarily, I have little faith in assertions such as I described actually
> being accurate. It is my opinion that they tend to arise when people look for
> design patterns to apply, instead of trying to judge which design patterns are
> appropriate (perhaps a subtle distinction). The structure of the Singleton
> pattern is relatively easy to understand, which makes the pattern low-hanging
> fruit for pattern seekers.
>
> I am in agreement with other respondents that it is frequently best to simply
> create only those objects you need, without applying special structure to your
> classes. It may be useful to have a registry of particular objects used by
> your application; with a Singleton, the class itself serves as such a
> registry, but there is no special need for that. In fact, unless there is a
> particular need that the same object be used everywhere throughout the
> application, I would do away with any central registry.
>
What about a situation where you frequently use a stateless object to service
other objects? If the service object is not a singleton, hundreds or thousands
of them might be created and discarded in a short time. As a singleton, only the
one instance is ever created, and this is perfectly sufficient. Would you
consider this a valid reason to use the pattern?
- Next message: Ryan Stewart: "Re: Singleton --- almost"
- Previous message: Bill Tschumy: "Re: what can't you do in swing but in awt?"
- In reply to: John C. Bollinger: "Re: Singleton --- almost"
- Next in thread: Andrew McDonagh: "Re: Singleton --- almost"
- Reply: Andrew McDonagh: "Re: Singleton --- almost"
- Reply: John C. Bollinger: "Re: Singleton --- almost"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|