home bbs files messages ]

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,716 of 33,346   
   Gene Bushuyev to goran...@googlemail.com   
   Re: Singletons   
   10 Dec 12 14:30:28   
   
   From: publicfilter@gbresearch.com   
      
   On Tuesday, December 4, 2012 12:40:00 PM UTC-8, goran...@googlemail.com wrote:   
   > On Monday, November 26, 2012 3:10:08 AM UTC+1, fmatthew5876 wrote:   
   >   
   > >Anti-pattern or not there will always be a need for managing global state.   
   [snip]   
   > There is no such thing as "global state",   
   > except in simplest of programs.   
      
   I wish that were true. I would say just the opposite, getting   
   rid of global states is easy in simplest of programs, it can   
   be difficult and expensive in real life. As I mentioned before,   
   the "routing" of dependencies is the simplest of problems, the   
   increased size and performance hit can be more serious, but   
   the worst part is a lot more complicated logic.   
   Here is one example of global state right from the C++ standard,   
   namely "free store". Now, try to design a program to get rid   
   of it, start with every object taking an allocator object.   
   Next, let it not to assume that allocators are all the same,   
   so comparison, copying, etc. have to be correct in the presence   
   of different allocators. Next, you don't have raw pointers   
   anymore, so be careful not to use standard library functions   
   that assume that. And find the standard containers, which   
   actually correctly implement allocators -- you'll probably   
   have to go with Boost as the others don't do it correctly.   
   Now, after your program got 10 times bigger, slower, fatter,   
   and 1000's times more complex, ask yourself, do you really   
   need to pay that much to get rid of the global free store   
   when in reality all the allocators are the same?   
      
      
   --   
         [ 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