<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Who told Java Checked Exceptions were a Bad Idea?</title>
	<atom:link href="http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/feed/" rel="self" type="application/rss+xml" />
	<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/</link>
	<description>Sadek Drobi</description>
	<lastBuildDate>Mon, 02 Nov 2009 05:56:20 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: alec</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-19913</link>
		<dc:creator>alec</dc:creator>
		<pubDate>Sun, 04 Oct 2009 19:25:50 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-19913</guid>
		<description>At first, i thought this blog was dated 2003 or so... Here&#039;s a good article that, i find, explains quite a bit, including the popular misconceptions about exceptions. What the article does very well is explain why you don&#039;t need a compiler alert to have no surprises.

http://constv.blogspot.com/2009/08/error-handling-and-exceptions-in-java.html

Cheers,
Alec</description>
		<content:encoded><![CDATA[<p>At first, i thought this blog was dated 2003 or so&#8230; Here&#8217;s a good article that, i find, explains quite a bit, including the popular misconceptions about exceptions. What the article does very well is explain why you don&#8217;t need a compiler alert to have no surprises.</p>
<p><a href="http://constv.blogspot.com/2009/08/error-handling-and-exceptions-in-java.html" rel="nofollow">http://constv.blogspot.com/2009/08/error-handling-and-exceptions-in-java.html</a></p>
<p>Cheers,<br />
Alec</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper Bang</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-18679</link>
		<dc:creator>Casper Bang</dc:creator>
		<pubDate>Wed, 26 Aug 2009 13:17:16 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-18679</guid>
		<description>The problem is not checked exceptions as a concept, as they obviously represents a boost to static checking at the expense of leaking abstraction (you will want to guard layer boundaries). No the problem is how they are implemented in Java. 1) You can not rethrow, only wrap 2) The hierachy is screwed, you can&#039;t choose to only catch CheckedException while letting UncheckedExceptions bubble up 3) The Java libraries are horrible guidelines at how you should use checked exceptions.</description>
		<content:encoded><![CDATA[<p>The problem is not checked exceptions as a concept, as they obviously represents a boost to static checking at the expense of leaking abstraction (you will want to guard layer boundaries). No the problem is how they are implemented in Java. 1) You can not rethrow, only wrap 2) The hierachy is screwed, you can&#8217;t choose to only catch CheckedException while letting UncheckedExceptions bubble up 3) The Java libraries are horrible guidelines at how you should use checked exceptions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manuel aldana</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-13368</link>
		<dc:creator>manuel aldana</dc:creator>
		<pubDate>Sat, 11 Apr 2009 08:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-13368</guid>
		<description>you mentioned you don&#039;t like surprises. You&#039;re right there should be no suprises when it comes to exceptional conditions but this should be done through documentation of exceptions. But the runtime behaviour you should be backuped with a good test coverage (then you see all these traces and can add error-handling code appropriatly. If done so then you don&#039;t get suprises in production system.

My two cents also as a blog entry (I am favoring unchecked exceptions only approach):
www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/</description>
		<content:encoded><![CDATA[<p>you mentioned you don&#8217;t like surprises. You&#8217;re right there should be no suprises when it comes to exceptional conditions but this should be done through documentation of exceptions. But the runtime behaviour you should be backuped with a good test coverage (then you see all these traces and can add error-handling code appropriatly. If done so then you don&#8217;t get suprises in production system.</p>
<p>My two cents also as a blog entry (I am favoring unchecked exceptions only approach):<br />
<a href="http://www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/" rel="nofollow">http://www.aldana-online.de/2008/07/28/getting-rid-of-checked-exceptions-in-java/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MF2002</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-9532</link>
		<dc:creator>MF2002</dc:creator>
		<pubDate>Wed, 11 Mar 2009 17:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-9532</guid>
		<description>The problem with checked exceptions in Java is that they are often ignored.  And for good reason.  If an SQLException occurs, for instance, it could be because of:
1.  Bad SQL grammar
2.  The DB doesn&#039;t like you right now
3.  The connection to the DB has an issue
4.  Other

3 and 4 cannot always be resolved, and they&#039;re usually *not* related to SQL at all.  The same issue occurs with checked IOExceptions - generally, if you try and catch an IOException upon close, and one actually happens, normally, there&#039;s nothing you can do about it - and who cares, because you&#039;ve closed the resource and shouldn&#039;t use it again anyways!

RuntimeExceptions, such as those used by Spring, are much more informative, and the best part is that they are optional.  If all the exceptions were optional, you probably wouldn&#039;t have the problem of naive programmers doing a try-catch and squeltching an exception at an inappropriate time.  Checked exceptions force you to handle them, but as for your &quot;Customer&quot; method - why care about the internals?  You could have a checked or runtime exception, but then every time you have to retrieve a customer you have to try catch.  If you just throw a runtime exception, you&#039;ll have the same information as a checked exception, and no one will make empty try catch blocks because they get annoyed at having to try-catch all the time (it does happen, although I generally log exceptions or place comments saying that they were intentionally ignored).

The most basic problem with checked exceptions, though, is not that they&#039;re checked - it&#039;s that the exception that is thrown from Java&#039;s checked exceptions often has *nothing* to do with the actual problem - you have to dig deeper into the exception.  Specific RuntimeExceptions are more easily caught when you *can* deal with the problem, and just as easily ignored when you cannot (if your customer processing method can&#039;t get a customer, what should it do?  Catch and then return, or throw the exception?  I would just throw the exception, because then something would be wrong that the customer processing method cannot do anything about - and that&#039;s what runtime exceptions do for you by default).</description>
		<content:encoded><![CDATA[<p>The problem with checked exceptions in Java is that they are often ignored.  And for good reason.  If an SQLException occurs, for instance, it could be because of:<br />
1.  Bad SQL grammar<br />
2.  The DB doesn&#8217;t like you right now<br />
3.  The connection to the DB has an issue<br />
4.  Other</p>
<p>3 and 4 cannot always be resolved, and they&#8217;re usually *not* related to SQL at all.  The same issue occurs with checked IOExceptions &#8211; generally, if you try and catch an IOException upon close, and one actually happens, normally, there&#8217;s nothing you can do about it &#8211; and who cares, because you&#8217;ve closed the resource and shouldn&#8217;t use it again anyways!</p>
<p>RuntimeExceptions, such as those used by Spring, are much more informative, and the best part is that they are optional.  If all the exceptions were optional, you probably wouldn&#8217;t have the problem of naive programmers doing a try-catch and squeltching an exception at an inappropriate time.  Checked exceptions force you to handle them, but as for your &#8220;Customer&#8221; method &#8211; why care about the internals?  You could have a checked or runtime exception, but then every time you have to retrieve a customer you have to try catch.  If you just throw a runtime exception, you&#8217;ll have the same information as a checked exception, and no one will make empty try catch blocks because they get annoyed at having to try-catch all the time (it does happen, although I generally log exceptions or place comments saying that they were intentionally ignored).</p>
<p>The most basic problem with checked exceptions, though, is not that they&#8217;re checked &#8211; it&#8217;s that the exception that is thrown from Java&#8217;s checked exceptions often has *nothing* to do with the actual problem &#8211; you have to dig deeper into the exception.  Specific RuntimeExceptions are more easily caught when you *can* deal with the problem, and just as easily ignored when you cannot (if your customer processing method can&#8217;t get a customer, what should it do?  Catch and then return, or throw the exception?  I would just throw the exception, because then something would be wrong that the customer processing method cannot do anything about &#8211; and that&#8217;s what runtime exceptions do for you by default).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stas</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-8496</link>
		<dc:creator>Stas</dc:creator>
		<pubDate>Thu, 05 Feb 2009 10:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-8496</guid>
		<description>Wierd post. Makes things complex. In reality all is simple covered by follwoing three statements:
- checked exceptions are business ones 
- unchecked - technical, system errors
- any code any time can throw exception and developer has to take it into account. That&#039;s Java&#039;s nature.

Using DaoException has no much sense - it doens&#039;t say anything, just that method can throw exception, which is known just by definition. But it adds lots of pain in neck for guys who have to think what to do with it next - add to throws or wrap with another or anything else...

Hope it helps :)</description>
		<content:encoded><![CDATA[<p>Wierd post. Makes things complex. In reality all is simple covered by follwoing three statements:<br />
- checked exceptions are business ones<br />
- unchecked &#8211; technical, system errors<br />
- any code any time can throw exception and developer has to take it into account. That&#8217;s Java&#8217;s nature.</p>
<p>Using DaoException has no much sense &#8211; it doens&#8217;t say anything, just that method can throw exception, which is known just by definition. But it adds lots of pain in neck for guys who have to think what to do with it next &#8211; add to throws or wrap with another or anything else&#8230;</p>
<p>Hope it helps :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karsten Blees</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-7854</link>
		<dc:creator>Karsten Blees</dc:creator>
		<pubDate>Thu, 15 Jan 2009 03:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-7854</guid>
		<description>AFAIK checked exceptions will not be supported in .Net 4.0 (at least not in C#, see http://code.msdn.microsoft.com/csharpfuture), where did you get that information?

The page you mentioned above is about the new design by contract features in .Net. This DbC stuff, along with automated test case generation (see the Pex tool demonstrated in the video), really looks promising, and I strongly believe that this is where we&#039;re heading.

Compared to DbC and Pex, checked exceptions seem to be a quite primitive and inconsistent &quot;feature&quot;. Consider this:

  private static final URL namespace = new URL(&quot;http://example.com/specs/2009/etc&quot;);

This code is simple, concise, and - as far as the JVM is concerned - correct. However, the java compiler will report an error due to the checked exception declared by the URL constructor. Let&#039;s try to &quot;fix&quot; it:

  private static final URL namespace;
  static {
    try {
      namespace = new URL(&quot;http://example.com/specs/2009/etc&quot;);
    } catch (MalformedURLException mue) {
      throw new AssertionError(&quot;unreachable&quot;);
    }
  }

Adding those seven (!) lines of code solved the compiler issue, but now it is impossible to achieve more than 33% code coverage in regression tests, because the exception handler code can never be reached. Code coverage essentially becomes useless as a quality measure - if I get less than 100%, I&#039;ll never know if I missed something in the unit test, or if it&#039;s due to some darned unreachable checked exception handler. (But why bother writing unit tests at all, the compiler already told me that everything was fine, right?)

There are many more examples where checked exceptions force you to write unreachable code (String.getBytes(&quot;UTF-8&quot;), MessageDigest.getInstance(&quot;MD5&quot;), all uses of ByteArrayInput/OutputStream or StringReader/Writer...). In a language that otherwise reports unreachable code as errors, this has to be considered a bug in the language design.

In .Net 4.0, with a tool at hand to automatically devise test cases that cover all branches in the code (such as Pex), there is clearly no need for a feature that introduces unreachable code as a side effect (however promising the concept may sound in theory).

I really would like to see things like DbC and Pex in Java. However, considering how many people still believe that checked exceptions are a good idea, I don&#039;t think that it&#039;ll happen soon...</description>
		<content:encoded><![CDATA[<p>AFAIK checked exceptions will not be supported in .Net 4.0 (at least not in C#, see <a href="http://code.msdn.microsoft.com/csharpfuture)" rel="nofollow">http://code.msdn.microsoft.com/csharpfuture)</a>, where did you get that information?</p>
<p>The page you mentioned above is about the new design by contract features in .Net. This DbC stuff, along with automated test case generation (see the Pex tool demonstrated in the video), really looks promising, and I strongly believe that this is where we&#8217;re heading.</p>
<p>Compared to DbC and Pex, checked exceptions seem to be a quite primitive and inconsistent &#8220;feature&#8221;. Consider this:</p>
<p>  private static final URL namespace = new URL(&#8221;http://example.com/specs/2009/etc&#8221;);</p>
<p>This code is simple, concise, and &#8211; as far as the JVM is concerned &#8211; correct. However, the java compiler will report an error due to the checked exception declared by the URL constructor. Let&#8217;s try to &#8220;fix&#8221; it:</p>
<p>  private static final URL namespace;<br />
  static {<br />
    try {<br />
      namespace = new URL(&#8221;http://example.com/specs/2009/etc&#8221;);<br />
    } catch (MalformedURLException mue) {<br />
      throw new AssertionError(&#8221;unreachable&#8221;);<br />
    }<br />
  }</p>
<p>Adding those seven (!) lines of code solved the compiler issue, but now it is impossible to achieve more than 33% code coverage in regression tests, because the exception handler code can never be reached. Code coverage essentially becomes useless as a quality measure &#8211; if I get less than 100%, I&#8217;ll never know if I missed something in the unit test, or if it&#8217;s due to some darned unreachable checked exception handler. (But why bother writing unit tests at all, the compiler already told me that everything was fine, right?)</p>
<p>There are many more examples where checked exceptions force you to write unreachable code (String.getBytes(&#8221;UTF-8&#8243;), MessageDigest.getInstance(&#8221;MD5&#8243;), all uses of ByteArrayInput/OutputStream or StringReader/Writer&#8230;). In a language that otherwise reports unreachable code as errors, this has to be considered a bug in the language design.</p>
<p>In .Net 4.0, with a tool at hand to automatically devise test cases that cover all branches in the code (such as Pex), there is clearly no need for a feature that introduces unreachable code as a side effect (however promising the concept may sound in theory).</p>
<p>I really would like to see things like DbC and Pex in Java. However, considering how many people still believe that checked exceptions are a good idea, I don&#8217;t think that it&#8217;ll happen soon&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sadache</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-7646</link>
		<dc:creator>Sadache</dc:creator>
		<pubDate>Tue, 06 Jan 2009 10:13:57 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-7646</guid>
		<description>@Brandon The worst case scenario you are describing for checked exceptions is the normal situation for unchecked, the exception bubbles up. However, with Checked Exceptions the problem is very easy to spot using modern IDEs or static analyses tools but nearly impossible to detect with Runtime Exceptions!</description>
		<content:encoded><![CDATA[<p>@Brandon The worst case scenario you are describing for checked exceptions is the normal situation for unchecked, the exception bubbles up. However, with Checked Exceptions the problem is very easy to spot using modern IDEs or static analyses tools but nearly impossible to detect with Runtime Exceptions!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-7638</link>
		<dc:creator>Brandon</dc:creator>
		<pubDate>Tue, 06 Jan 2009 03:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-7638</guid>
		<description>A couple of thoughts here. Let it be known that I&#039;m firmly in the Unchecked exception camp. :-)

1) There&#039;s no reason you can&#039;t declare the throws clause on  the method signature when using unchecked exceptions.

Customer getCustomer(CustomerId id) throws UncheckedDaoException;

Your method signature is now self describing and hides no details.

2) Based on the lazy/incompetent programmer scenario, I&#039;ve seen *lots* of code that deals with exceptions by bubbling them because the code doesn&#039;t know how to handle them.

void Foo() throws MalformedUrlException, FileNotFoundException, ClassNotFoundException, SomeCustomApplicationException {
   // Crazy logic goes here.
}

Later, one of those aforementioned programmers sees that ugly mess of a throws clause and decides to clean it up:

void Foo() throws Exception {
  // Same crazy logic goes here.
}

Ah, much cleaner. Unfortunately, it now tells me exactly as much information as:

void Foo() {
  // Same crazy logic goes here.
}

And if that doesn&#039;t happen, invariably the aforementioned programmer will code the caller in this fashion:

void Bar() {
  try {
    Foo();
  }
  catch(Exception e) {
    // &quot;Handle&quot; error here.
  }
}

Again, we have a situation where a generic catch all is happening when it shouldn&#039;t be. What happens if Foo throws an IndexOutOfBoundsException? This is very likely a programming error and not simply something that we can &quot;handle&quot; and move on.</description>
		<content:encoded><![CDATA[<p>A couple of thoughts here. Let it be known that I&#8217;m firmly in the Unchecked exception camp. :-)</p>
<p>1) There&#8217;s no reason you can&#8217;t declare the throws clause on  the method signature when using unchecked exceptions.</p>
<p>Customer getCustomer(CustomerId id) throws UncheckedDaoException;</p>
<p>Your method signature is now self describing and hides no details.</p>
<p>2) Based on the lazy/incompetent programmer scenario, I&#8217;ve seen *lots* of code that deals with exceptions by bubbling them because the code doesn&#8217;t know how to handle them.</p>
<p>void Foo() throws MalformedUrlException, FileNotFoundException, ClassNotFoundException, SomeCustomApplicationException {<br />
   // Crazy logic goes here.<br />
}</p>
<p>Later, one of those aforementioned programmers sees that ugly mess of a throws clause and decides to clean it up:</p>
<p>void Foo() throws Exception {<br />
  // Same crazy logic goes here.<br />
}</p>
<p>Ah, much cleaner. Unfortunately, it now tells me exactly as much information as:</p>
<p>void Foo() {<br />
  // Same crazy logic goes here.<br />
}</p>
<p>And if that doesn&#8217;t happen, invariably the aforementioned programmer will code the caller in this fashion:</p>
<p>void Bar() {<br />
  try {<br />
    Foo();<br />
  }<br />
  catch(Exception e) {<br />
    // &#8220;Handle&#8221; error here.<br />
  }<br />
}</p>
<p>Again, we have a situation where a generic catch all is happening when it shouldn&#8217;t be. What happens if Foo throws an IndexOutOfBoundsException? This is very likely a programming error and not simply something that we can &#8220;handle&#8221; and move on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Pratt</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-7635</link>
		<dc:creator>Daniel Pratt</dc:creator>
		<pubDate>Tue, 06 Jan 2009 02:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-7635</guid>
		<description>I much prefer C# over Java, mostly due to familiarity. That being said, I greatly wish C# had checked exceptions.</description>
		<content:encoded><![CDATA[<p>I much prefer C# over Java, mostly due to familiarity. That being said, I greatly wish C# had checked exceptions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sadache</title>
		<link>http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/comment-page-1/#comment-7628</link>
		<dc:creator>Sadache</dc:creator>
		<pubDate>Mon, 05 Jan 2009 20:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://sadekdrobi.com/2009/01/04/who-told-java-checked-exceptions-were-a-bad-idea/#comment-7628</guid>
		<description>@Jurai
I frankly don&#039;t see the issues Jonathan and your article referenced as problems in the Checked Exceptions but rather a result of lack of design and abstraction skills . Same problems will gradually appear when these exceptions are discovered at runtime, and addressed by same incompetent people. As many of the software developers do not stay long enough after the software is deployed in production, they tend to think that they got rid of exceptions by ignoring them.  
Checked Exceptions only make these issues apparent. Now as for examples of IO and SQL Checked Exceptions (the main motivation of my post), I already know that there were/still are a lot of arguments against them preferring Runtime Exception, but mostly for false reasons.

One of the funny arguments is that you do not need to pollute you code with infrastructure errors that are rare to happen, well if you stay long enough to see life in production you&#039;ll discover that they are not as rare as you thought. And guess what, The end user &quot;catches&quot; the exception instead of the developer, with sometimes some pretty sensitive information passed even through the World Wide Web!
Well, now with a good design, knowing at compile time that you need to handle the infrastructure errors, you create your own &quot;infrastructure checked exception&quot; where you wrap the kind of exception hiding sensitive information and logging what has to be logged. This way you are sending a message to the user of your service that, there is an infrastructure behind that can fail, and that he needs to think about represent the case for his service user, and so on. This is for a healthy architecture that does not delay production problems until production because they tend not to happen in dev environment.

In the same way, I don&#039;t see how this can affect encapsulation, again in some often mentioned examples, of one file based logging, and another database log. Well you need to do an abstraction which is a logging exception that wraps logging infrastructure errors. And Checked Exceptions will help me to make sure that the end user will not receive a Logging Exception kind of error!

versioning is the same issue as in any type in the contract. I don&#039;t guess a java programmer will change to return an int instead of an Integer because he decided. This is not an issue of Exceptions but rather a normal problem of Producer/Consumer design that you have even in dynamic languages.

I seriously think that J2EE, with the effect of mainstream frameworks, abandoned Java Checked Exceptions way too often.</description>
		<content:encoded><![CDATA[<p>@Jurai<br />
I frankly don&#8217;t see the issues Jonathan and your article referenced as problems in the Checked Exceptions but rather a result of lack of design and abstraction skills . Same problems will gradually appear when these exceptions are discovered at runtime, and addressed by same incompetent people. As many of the software developers do not stay long enough after the software is deployed in production, they tend to think that they got rid of exceptions by ignoring them.<br />
Checked Exceptions only make these issues apparent. Now as for examples of IO and SQL Checked Exceptions (the main motivation of my post), I already know that there were/still are a lot of arguments against them preferring Runtime Exception, but mostly for false reasons.</p>
<p>One of the funny arguments is that you do not need to pollute you code with infrastructure errors that are rare to happen, well if you stay long enough to see life in production you&#8217;ll discover that they are not as rare as you thought. And guess what, The end user &#8220;catches&#8221; the exception instead of the developer, with sometimes some pretty sensitive information passed even through the World Wide Web!<br />
Well, now with a good design, knowing at compile time that you need to handle the infrastructure errors, you create your own &#8220;infrastructure checked exception&#8221; where you wrap the kind of exception hiding sensitive information and logging what has to be logged. This way you are sending a message to the user of your service that, there is an infrastructure behind that can fail, and that he needs to think about represent the case for his service user, and so on. This is for a healthy architecture that does not delay production problems until production because they tend not to happen in dev environment.</p>
<p>In the same way, I don&#8217;t see how this can affect encapsulation, again in some often mentioned examples, of one file based logging, and another database log. Well you need to do an abstraction which is a logging exception that wraps logging infrastructure errors. And Checked Exceptions will help me to make sure that the end user will not receive a Logging Exception kind of error!</p>
<p>versioning is the same issue as in any type in the contract. I don&#8217;t guess a java programmer will change to return an int instead of an Integer because he decided. This is not an issue of Exceptions but rather a normal problem of Producer/Consumer design that you have even in dynamic languages.</p>
<p>I seriously think that J2EE, with the effect of mainstream frameworks, abandoned Java Checked Exceptions way too often.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

