On Tuesday 6 December 2005 03.04, David Johnson wrote:

> Here's the style of code that causes me to reach for that little baggie:
>
> void function() {
> try {


Gag! Now you're making me do it again :-)

> I'm sorry that my tiny gripe spun off into such a contentious debate,
> but maybe, just maybe, it's a sign that exceptions aren't the wonderfully
> simplistic panaceas that people think they are. Perhaps there are some
> pitfalls and drawbacks associated with them.


There are. Ofcourse there are. Luckily - or sadly - the world is not flat. And
in this type of discussion one of the things that happen is that people try
to make the world look flat. That said, no, using exceptions is not a
panacea, and one should use a certain amount of design in order to use them
properly, however, in the C++ case using them makes it possible to express
oneself differently.Constructions like:

object[childTwo].performOp().performAnotherOp()

are totally impossible to write if one is restrained to do error handling by
returning and evaluating a statuscode. So, my conclusion is that the concept
of exceptions and using them in a diligent way can hugely improve the
expressiveness of C++ as a language.

As for 'design' what I tend to do - and I also do that in Java - is to
carefully think out a module structure for my sources. Similar things go into
one module. The only exception type escaping from module XXX is
XXX::Exception. Inside it is information what caused the exception, a bit
like a trace of what exception was caused by what other exception. This
simplifies handling them and gives somebody that needs to debug the code an
idea where the original error occurred and what path was taken.

--
R.F. Pels, 3e Rompert 118, 5233 AL 's-Hertogenbosch, The Netherlands
+31736414590 ruurd@tiscali.nl http://home.tiscali.nl/~ruurd


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