On Tuesday, March 4, 2003, at 03:12 AM, Aashit Soni wrote:
Do we have singleton class?
if we dont have that and think to have it - i'd designed one simple _singleton<> that works good to make parameter class singleton..

I've done much work with singletons, and I've come around to the opinion that they should not be implemented as wrappers. Singleton status of a class should be designed in from the beginning and enforced at the class level, otherwise it's all too common to use any old class wrapped in a singleton holder as a global variable. I find myself falling into that trap when I have a class for which I want only one instance but there is no real reason why there couldn't be more. I only need one so I use a singleton. If you enforce the choice at design time by having it be an inheritable trait rather than a wrapper, it's less likely to be used as a mere convenience, and more likely to indicate a class for which there should conceptually be exactly one instance.


-- Brian

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to