About use of specific error

Markus Gaelli gaelli at emergent.de
Thu Mar 2 12:49:35 UTC 2006


Hi Boris,

>> The consequence is that it can be tedious to capture only specific
>> error.
> Yes, it is often necessary to ask an exception for its message
> text to understand what happened.

Could you give an example please?

I am still not convinced that the idiom of "first (possibly) hitting  
the wall, and then asking for the door" is a good one to teach  
students programming.
I think it would be better to teach students a _defensive_ way of  
programming, that is to ask first, if everything is ok, using some  
boolean queries and if these queries do not exist, let them write  
these queries and _not_ exception hierarchies.

Exceptions are a way of goto programming and can become quite hairy  
to use. I am glad to be in sync here with Andrew Thomas and Dave Hunt  
in their nice book about the pragmatic programmer.
They write something like using exceptions should be actually saved  
for situations, the developer cannot predict, such as external io- 
failures etc.

I am all for letting the programmers know which precondition they  
violated calling a method, but only for debugging their code, and not  
for using that info _in_ their code.

I am aware that there is a slight performance penalty to ask if  
everything is ok first all the times, also when everything _is_ ok.
But I'd teach above idiom more as the exception than as the  
rule... ;-) -- if at all.

Cheers,

Markus




More information about the Squeak-dev mailing list