Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,738 of 33,346    |
|    Balog Pal to Dave Abrahams    |
|    Re: Singletons    |
|    16 Dec 12 07:29:13    |
      From: pasa@lib.hu              On 12/2/2012 4:04 AM, Dave Abrahams wrote:       > Please, everyone, before arguing for Singleton,              In most singleton threads I sad in the last decade arguments were put       not FOR singleton, but AGAINST singleton-bashing.              > take some time to       > research the arguments against it and understand how Dependency       > Injection addresses those issues.              Honestly I didn't see the actual problems of singletons actually listed       in those DI-proponent articles, let alone address them. In a general       sense at least.              PFA, and singleton both have pros and cons, that we programmers should       match against the actual situation and go with the better. Or refactor       the system.              As for DI, that looks like a new branch in PFA I personally see it way       more poisonous than the singleton approach, and would not be surprised       at all if 10 years ahead we saw more DI-bashing threads than singleton       bashing today.              As sure, widening the global state is not good -- but if it's easy to       locate the *few* spots interested in the part really, it may be mitigated.              argument-based PFA blurs that possiblity, and DI does even worse, it       widens the object's state, for many objects. It makes actual usage less       visible rather than more visible as claimed. And another side effect       that it has tendency to create over-engineered solutions. And way more       overengineered ones than Singletons::MySingleton::GetTheInstance() crap.              I did experience so much bloat following those bashing threads, for most       everyday topics, assignment to flags replacing break, 8-level nested ifs       replacing an early guard-clause return, pasted code-blocks replacing       goto CLEANUP (in C); tons of getter/setters replacing public data in       structs equivalent to std::tuple, and many others.              Yes, globals and singletons CAN be bad for many reasons. But in many       situations those reasons don't apply at all.              But experience shows that due to general bashing many people will stop       evaluating reasons, just jump to use the strongly and emotionally       suggested alternative. Creating a worse system and way more work to       those who actually understand SW engineering.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca