Singleton question (shared class)

Ali Çehreli acehreli at yahoo.com
Thu Jan 26 11:13:11 PST 2012


On 01/25/2012 06:35 AM, Mars wrote:

 > I have a few classes which I want to implement as singletons (like
 > configuration, database connection, etc.), because I have to access them
 > throughout my whole program, and from different threads.

You haven't asked, so I shouldn't be commenting on your design, but 
singleton is accepted as an anti-pattern for a long time now. It is more 
like a solution in search of a problem. For example, in your case, you 
can solve your problems by creating just one of those objects and pass 
them down to code that will use them.

What prompted me to write this post is the following quote from the 
recent article of Pete Goodliffe in the ACCU's CVu magazine (volume 23, 
issue 6, January 2012):

<quote="Pete Goodliffe">
In this little saunter through software complexity territory we've seen 
that complexity arises from blobs (our software components), lines (the 
connections between those components), but mostly from people (the 
muppets who construct these software disasters).

Oh, and of course, it comes from the Singleton design pattern. But no 
one uses that any more, do they?
</quote>

Ali



More information about the Digitalmars-d-learn mailing list