HTML5 Canvas
Written by: Simon Sarris
Featured Refcardz: Top Refcardz:
  1. Apache Hadoop
  2. Web Driver
  3. MVVM
  4. REST
  5. ADO.NET
  1. HTML5
  2. Ajax
  3. jQuery Selectors
  4. CSS Part 1
  5. Git

Link Details

Link 23617 thumbnail
User 111696 avatar

By bloid
via gafter.blogspot.com
Published: May 27 2007 / 17:51

There has been an ongoing debate on the utility of checked exceptions. Many people are critical of Java's checked exceptions, characterizing them as a failed experiment in software engineering. In practice, checked exceptions can result in API complexity, and programs appear to be cluttered with exception handling code just to satisfy the compiler. Some people believe checked exceptions are a good language feature but are misused, even in the JDK. With the "experts" being such poor role models, how can we expect ordinary Java programmers to do better?
  • 14
  • 1
  • 1556
  • 0

Comments

Add your comment
User 133619 avatar

murban replied ago:

3 votes Vote down Vote up Reply

Personally, I think checked exceptions are a good thing, and one of the reasons that Java is so well suited for mission critical applications. Of course, the problem is that programmers often defeat the purpose by simply catching the exceptions and ignoring them just to satisfy the compiler, instead of recovering from them in a graceful way. But this is not a defect in the concept of checked exceptions. Rather it is a failure on the part of developers to take advantage of the features of Java that allow them to write more reliable and fault tolerant software.

User 180410 avatar

Mihai Campean replied ago:

2 votes Vote down Vote up Reply

I agree, we should not blame nor change a good thing because of our inability to understand and use it properly. I have been searching for best practices in exception handling for Java but I could not find a simple and useful way that can be generally applied. I guess this is one of those "no silver bullet" things, however we shouldn't give up hope on it just yet.

User 186344 avatar

kunnar replied ago:

-2 votes Vote down Vote up Reply

But most of the time there is nothing else to do with checked exception than wrap it to RuntimeException and throw it. I am not saying that checked exceptions are bad, but they are definately overused in Java. Here is good discussion about checked and unchecked exceptions: http://dev2dev.bea.com/pub/a/2006/11/effective-exceptions.html

User 212375 avatar

georgi replied ago:

1 votes Vote down Vote up Reply

Checked exceptions are not overused in Java. I confess that I do like a programming language / core API that forces me to catch exceptions via compiler errors (where applicable) more than the .NET - stuff that does not even precisely explain when which exception may raise eventually in which condition (or not). Yes, I worked with that stuff to. And visiting your link and due to all respect for BEA, sentences like "An I/O failure is a serious but extremely rare event. On top of that, there is usually nothing your code can do to recover from one." - that is not beareable. An I/O failure may occur one in a million (heck, let's say one in a trillion), but the programmer has to be aware that it _might happen all the time_ . That's what checked exceptions are for, to understand my opinion look at the last chapter of: http://www.dzone.com/links/thoughts_on_successful_exception_handling.html

User 186344 avatar

kunnar replied ago:

0 votes Vote down Vote up Reply

Looks like different people have different views on this. I can give another link for just showing that there are good programmers who are thinking that checked exceptions are overused in Java. For example Spring Framework people have written this right into there mission statement:

Checked exceptions are overused in Java. A framework shouldn't force you to catch exceptions you're unlikely to be able to recover from.

Link: http://www.springframework.org/about

User 230377 avatar

tom.palmer.myopenid.com replied ago:

-2 votes Vote down Vote up Reply

Don't mean to be a troll, but Java checked exceptions are just terrible. Everything is bad about them except in fairy tales. I've gone into more detail on other occasions. Just casting a quick vote here.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.