Jon Stewart on 19 Jun 2003 18:19:01 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [ALACPP] Singleton clarification


> Overall, I have to agree with Chris on the Singleton issue. This is especiall
> y
> the case in C++ in Windows. We had merry hell last winter because our system
> was divided into multiple DLLs. Static variables are one-per-PE-per-process,
> and wre the usual low-level implementation of singletons. Thus, what we thoug
> h
> was one-per-process was actually one-per-DLL-per-process, and the sharing of
> data didn't work out well.
> 
> We eventually solved the problem by moving all of the singletons (5 of them)
> into their own DLL, and having all others use them from there. However, this
> was also lame.


<holds head in hands>

"Merry hell" is the perfect phrase.

Here's a recent interview with Kent Beck wherein he talks about Singletons 
sucking:

http://www-106.ibm.com/developerworks/java/library/j-beck/?ca=dgr-lnxw02KentBeck


> The real problem that I have with log4cpp isn't that they use singletons. It'
> s
> that they think that they're using singletons, but don't. They just use a
> bunch of mutually-dependent global static variables. They don't control
> ccreation or destruction order, even though the destructors for some of them
> use others of them. If they at least stepped up to singletons, then they coul
> d
> fix a number of their crash on close or leak on close bugs.


I've had discussions with Bastiaan about this. Some guy submitted a patch 
about a month and a half ago that solves a lot of the leak on close bugs.

I've thought a bit about fixing various things in log4cpp -- but I'm not 
convinced it has the right philosophy.

I believe, though, that Bastiaan is thinking about a major rewrite.


Jon
-- 
Jon Stewart
stew1@xxxxxxxxxxx
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp