Martin Wildam wrote:
> On Aug 22, 7:23 am, Peter Becker <peter.becker...@gmail.com> wrote:
>   
>> While I'm still arguing for checked exceptions, I'm not 100% convinced
>> their good yet either. But nearly every argument I see why they are bad
>> is about how they are used badly, with the conclusion of some intrinsic
>> badness.
>>     
>
> I agree with you. - But since (at least my opinion) exceptions are
> either used badly in some of the core Java APIs from Sun the question
> is really, how to get people - especially beginners - to understand
> how they are used correctly.
>   
Now that is a good question to ask.

Unfortunately when teaching about exceptions you will encounter some 
major poblems:
1) the first encounter with exceptions will be most likely the JDK, i.e. 
a bad example (and beginner's tend to think the JDK must have the best 
design ever)
2) to deal with exceptions you need to do the wrong things sometimes 
unless you avoid the JDK somehow
3) there doesn't seem to be much agreement on how to do it right in the 
community
4) most people who have experience claim that checked exceptions are 
intrinsically broken (IMO invalidly)

To me it feels like a big case of SNAFU, sustained by Sun's 
unwillingness to do anything that breaks backwards-compatibility. I 
think the only thing you can do to teach someone something decent about 
exceptions is to teach them different error handling approaches in the 
abstract, and make them aware that in many scenarios error handling can 
be the most complicated aspect of your code.

Someone should probably write a nice book talking only about error 
handling, the different ways to propagate errors (special return values, 
checked exceptions, unchecked exceptions, union types) and the different 
ways to deal with them. A nice chapter on logging strategies would be 
good, too. Maybe one on the errors you can't handle (stuff such as 
external errors, infinite loops, infinite recursion, resource leaks). 
Does anyone know of such a book or volunteer? :-)

  Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to