Singleton question (shared class)

Mars - at -.-
Thu Jan 26 12:11:30 PST 2012


On Thursday, 26 January 2012 at 19:13:11 UTC, Ali Çehreli wrote:
> 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.
>
> Ali

Thanks for your opinion.
Although I know singletons aren't exactly best practice in OOP, I 
simply can't live without them. Sure I could pass my objects down 
again and again, so I have them availale at some point, but in a 
bigger program this just gets tedious, and for me that's not what 
OOP is supposed to do. On the contrey, things should get easier, 
and cleaner. Maybe I'll change my mind some day (5 years ago I 
though OOP was nonsense after all), or some new solution may come 
along, but for the time being, singletons are valid practice in 
my eyes.

Mars


More information about the Digitalmars-d-learn mailing list