views:

191

answers:

1

Possible Duplicate:
The case against checked exceptions

EDIT: It appears I didn't phrase my question correctly, and I can understand the frustration.

I'm looking for some information that explains where I should use checked exceptions and where I should not use it. Most of the information on this subject is one sided - love/hate relationship. I think people make the assumption that one is bad over the other, or that developers always do a bad job about it.

EDIT 2: Ok, I did some Google searching (I wish I had done that before posting here), and found some balanced answers. I'm including them so it may help anyone looking for an answer, not another debate (like the duplicate post mentioned above)

http://www.ibm.com/developerworks/java/library/j-jtp05254.html

It appears Rod has a balanced discussion on this topic in his book, J2EE design without EJB:

http://www.theserverside.com/tt/articles/article.tss?l=RodJohnsonInterview

It also appears that if you use validation on domain object, it would not be a bad idea to use checked exceptions. Anyway, if you read the materials above, you could be convinced about not using checked exceptions or minimize the chances of using it.

Rich, has provided an excellent link. Thanks, Rich!

http://onjava.com/pub/a/onjava/2003/11/19/exceptions.html

Some more:

http://www.oracle.com/technology/pub/articles/dev2arch/2006/11/effective-exceptions2.html

http://www.joelonsoftware.com/items/2003/10/13.html

A: 

Shaw, try having checked exceptions in code implementing an Iterator.

Case closed :-D

Thorbjørn Ravn Andersen
that would be very dumb thing to do. I would use hasNext().
Shaw
The problem is that you _cannot_ throw checked exceptions through the Iterator interface as it doesn't declare any. Hence, any exceptions happening there, must be unchecked. See?
Thorbjørn Ravn Andersen
Most JDBC methods throw a checked exception, though that was not a good idea. The point is there could be cases where checked exceptions make sense.
Shaw
The problem I tried to indicate was what to do if you inside the hasNext() call code which throws a checked exception and the code using the iterator should know about it. You cannot do that directly as the hasNext() does not throw any checked exceptions.
Thorbjørn Ravn Andersen