On 12/10/2012 9:30 PM, Gene Bushuyev wrote:
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.
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.
Guess a few people here never worked with a message-pump based
environment. What is IMO quite a widespread thing for C++ (WIN32, GTK,
other UI frameworks...).
Where you have to pick your poison -- messy use of globals to
communicate cross messages or info-smuggling mechanism, that may get out
of hand very fast, and become even more messy.
Not to mention that most implementations of the smuggling-helpsers also
use global state under the hood (MFC temporary and permanent handlemaps
I'm a big fan of functional programming, especially the pure one like
scheme-withut-mutation. But if we chose C++ and real world things I see
no point pretending virginity.
Global state IS there, we better learn exactly how to deal with it, with
all pros&cons and alternatives.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]