C++ Code Smells
Richard <[email protected]> Tue, 27 Dec 2011 09:40:22 -0700
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Organization | multi-cellular, biological |
| Message-ID | <[email protected]> |
I'd previously written up a blog post on what I consider to be code
smells in C++:
<http://legalizeadulthood.wordpress.com/2009/07/30/c-code-smells/>
At that time I had the usual list of suspects:
void *
catch (...)
reinterpret_cast<T>
(T) expr aka C-style casts
Now I'm considering adding one more to the list:
static data
Static data makes it hard to add multithreading support to an
application or library because it cross-pollinates data across threads
instead of giving each thread it's own data. This may or may not be
important, but look at how much grief C library functions like ctime
or strtok give applications because of their use of static data.
Currently I'm debugging another issue related to static data and C++,
namely that the order in which static class objects are created or
destroyed is undefined. This is fine as long as all the destructors
are independent of each other, but when they have dependencies upon
each other and those dependencies are not made explicit by something
like a reference count, the resulting code has undefined behavior. In
my case, I'm lucky enough that it's crashing.
I know that some people consider Singleton pattern to actually be an
anti-pattern and in C++ Singleton generally means more static data.
I would like to hear the thoughts and opinions of others on the
subject of static data and whether you consider it smelly or not.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 version available for download
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
Legalize Adulthood! <http://legalizeadulthood.wordpress.com>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/refactoring/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/refactoring/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/