Re: win32 design patterns
* Alexander Nickolov:
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.
I'm not familiar with neither the fact nor the myth of binary code size reduction.
Source code size and complexity matters.
That's where you spend the time.
Where
I work C++ exceptions are strictly prohibited
If that is on embedded platform or e.g. kernel or device driver work, might be
reasonable or even necessary.
Otherwise, just incredibly stupid to use a lobotomized variant of the language:
it isn't designed for that, and it precludes using exception based libraries.
Use C instead.
since we care
about downloadable code size.
Ouch. Hope that isn't the only or a main reason.
Not to mention the hidden
complexity in properly handling C++ exceptions.
That's a myth, yes.
Exceptions automate failure handling. Failure handling is complex. Doing it
properly is hard enough with exceptions.
Without exceptions you have to implement effectively the same effect 100%
manually, relying on conventions, e.g. by peppering the code with if-clauses
checking return values and adding in redundant cleanup code, and mostly that is
a recipe for bugs, complexity and larger code size.
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.
That's not even wrong. :-)
Cheers,
- 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?