Re: win32 design patterns
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Thu, 28 Feb 2008 09:31:56 -0800
The "fact" that exceptions lead to reduced code size is a myth.
In reality, you can save up to 20% binary code size (coming from
actual code experiments) by disabling C++ exceptions. Where
I work C++ exceptions are strictly prohibited since we care
about downloadable code size. Not to mention the hidden
complexity in properly handling C++ exceptions.
As for two-phase initialization - this is not an anti-pattern. It's
quite useful in certain C++ designs because the initialization
can now be decoupled from the construction and can happen
in a completely different part of the code. I prefer the term
multi-phase initialization - initialization can happen in multiple
calls, not a single one. This helps with information hiding and
reduced coupling since different pieces know about the
initialization data. Or you might prefer the term setup since
initialization in C++ is usually associated with the constructor.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Alf P. Steinbach" <alfps@xxxxxxxx> wrote in message
news:13sd25p8r6g1r15@xxxxxxxxxxxxxxxxxxxxx
* Alex:
What are "Win32 design patterns"? Any design patterns are specific to
WIN32?
I don't know, but judging from Google search results it's just a
concatenation of two job requirements: familiarity with Win32 (presumably
the API), and with design patterns.
I know some design patterns written by Gamma (and 3 more are there).
It could be meaningful to label some of the patterns common in Win32
programming as "design patterns". But even more meaningful to label them
as "anti patterns"! E.g., the pattern of using default construction +
init method, common in MFC and in all COM-based code. Or, for another
Win32 anti pattern, the pattern of using HRESULTs to communicate failure
even within C++ code, instead of exceptions. Which reduces C++ to the
level of C (increasing code complexity and size).
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
- Follow-Ups:
- Re: win32 design patterns
- From: Alf P. Steinbach
- Re: win32 design patterns
- References:
- Re: win32 design patterns
- From: Alf P. Steinbach
- Re: win32 design patterns
- Prev by Date: Re: invoke non-static function using ::
- Next by Date: Re: Updating my Platform SDK
- Previous by thread: Re: win32 design patterns
- Next by thread: Re: win32 design patterns
- Index(es):
Relevant Pages
|