[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Those dern C++ exceptions
From:       Tim Jansen <tim () tjansen ! de>
Date:       2001-08-15 19:21:37
[Download RAW message or body]

On Wednesday 15 August 2001 16:57, Adriaan de Groot wrote:
> (tm) about exception handling. Of course, this was in the same sentence as
> "exceptions are gotos on steroids" and "Dijkstra's 'goto considered bad'
> is spot on," so you know that C++ exceptions *in* *general* are going to
> be dissed, not just any particular implementation thereof.

But this article is written from the perspective of somebody who obviously 
isn't used to exceptions. If you have exception you must know that every 
method that you call could throw an exception (unless you have the convention 
that you declare every exception, which is a good idea anyway). This isn't a 
bad thing, it can actually make code more readable, but you should always 
have have it in mind when using (or reading) methods that throw exceptions. 
Exceptions make it even more important to allocate objects on the stack 
instead of the heap, and it is also a good idea to check a method's arguments 
before using them. "throw exceptions early in the method" is a good rule of 
thumb. 
Often you can also make you life easier by declaring an object as invalid if 
it threw a certain exception. Then you only have to care for resource 
deallocation when an object threw an exception, and this is done easily by 
using stack-allocated objects.

bye...
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic