[Exceptional C++ Style] Item 12: Exception Safety: Is itWorth it?

Falcon, Pablo (IT) Pablo.Falcon at morganstanley.com
Thu Dec 2 17:46:48 EST 2004


Hi Ric,
> 
> In general I think you ought to as a matter of course, as it 
> often leads to "better" code (even if no exceptions occur.)
> 
> 
> 
> Except...

> - your team is proficient in non-exception code

Or non-proficient in exception code. :-)

> 
> It can cost in time, money, and quality to learn how to do it 
> in a new way, and if the code wasn't going to be any more 
> reliable, you have to consider not doing it.
> 
> - it would cost too much to add
> 
> eg an old exception-unsafe codebase that would get ripped to 
> shreds if an exception propagated. You're stuck with it.

In my experience the previous two points are very true. In general I
would prefer using exceptions to, say, return values, as an error
reporting methodology initially becase I quite dislike checking return
values time and time again. It clutters the code hiding the 'important
logic' in it, and it is also quite error prone... many people forget
checking return values once in a while. However, in my experience, I
have found that in most occasions it is difficult, if not impossible to
implement exception handling in the codebases I have had to work with.
These either disregard entirely exception handling or do a very poor job
(not implementing any of the guarantees most of the time, not creating
adequate exception hierarchies, etc.,etc.). In general I find most
people very unaware of how to work with exceptions safely. And let's be
honest, how many C++ programmers out there (percentage-wise) would look
dazzled when asked about the Abrahams guarantees? 80%? more? Not that I
consider myself an expert of any kind (quite the contrary) but I find
astonishing the level of unawareness that exists in the programming
community.

I don't know what you think, maybe your experiencies differ greatly from
mine, but many of the items in the Effective C++ series look to me more
like 'beautiful theory in an ideal world'. For sure I've had my taste of
the non-ideal one. :-(

Regards,

Pablo

 



> 
> -----------------------------------------
> Email provided by http://www.ntlhome.com/
> 
> 
> _______________________________________________
> Effective-cpp mailing list
> Effective-cpp at accu.org
> List: http://www.accu.org/mailman/listinfo/effective-cpp
> Project: http://www.paulgrenyer.dyndns.org/cppstyle/
> 
--------------------------------------------------------
 
NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited. 
 




More information about the Effective-cpp mailing list