<?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: Checked Exceptions: Failed Experiment?</title>
	<atom:link href="http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/</link>
	<description>A man needs a little madness, or else he never dares cut the rope and be free. -Nikos Kazantzakis</description>
	<lastBuildDate>Fri, 03 Feb 2012 00:04:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: oopexpert</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-396070</link>
		<dc:creator>oopexpert</dc:creator>
		<pubDate>Sun, 11 Sep 2011 20:57:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-396070</guid>
		<description>try {
URL u = new URL(“http://www.yahoo.com/”);
}
catch (MalformedURLException mue) { throw new RuntimeException(mue); }

This example refers to the API of java.net. As the API-Designer does not know in which context you will use the API this checked exception make sense. In your this case it is a constant in other cases the input comes from a user. As a user input it is an recoverable state. The user can be informed that the entered URL is incorrect and he must enter a correct one.

The API abstracts fully about low level exceptions. They may be raised like a broken connection but they are not visible to the caller because he would not be able to recover from this. So they are RuntimeExceptions.

I think this is a proper view on checked exception and I agree, that not every programmer is able to see the different semantics and at last the correct conclusion. Sometimes it is a kind of tricky...</description>
		<content:encoded><![CDATA[<p>try {<br />
URL u = new URL(“http://www.yahoo.com/”);<br />
}<br />
catch (MalformedURLException mue) { throw new RuntimeException(mue); }</p>
<p>This example refers to the API of java.net. As the API-Designer does not know in which context you will use the API this checked exception make sense. In your this case it is a constant in other cases the input comes from a user. As a user input it is an recoverable state. The user can be informed that the entered URL is incorrect and he must enter a correct one.</p>
<p>The API abstracts fully about low level exceptions. They may be raised like a broken connection but they are not visible to the caller because he would not be able to recover from this. So they are RuntimeExceptions.</p>
<p>I think this is a proper view on checked exception and I agree, that not every programmer is able to see the different semantics and at last the correct conclusion. Sometimes it is a kind of tricky&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-284096</link>
		<dc:creator>Joshua</dc:creator>
		<pubDate>Mon, 17 Jan 2011 21:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-284096</guid>
		<description>The first time I had to throw a checked exception through an interface that didn&#039;t allow it I understood *why* checked exceptions were broken.

The fact is simple in that it is too primitive a tool that cannot cope with higher-level algorithms.</description>
		<content:encoded><![CDATA[<p>The first time I had to throw a checked exception through an interface that didn&#8217;t allow it I understood *why* checked exceptions were broken.</p>
<p>The fact is simple in that it is too primitive a tool that cannot cope with higher-level algorithms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Beavis</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-219143</link>
		<dc:creator>Beavis</dc:creator>
		<pubDate>Wed, 02 Jun 2010 15:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-219143</guid>
		<description>OK, here are my examples, that immediately come to mind. There are a lot more of these, that I know I have to deal with on a continuous basis: exceptions that are _practically_ impossible.

  try {
    MessageDigest md = MessageDigest.getInstance(&quot;MD5&quot;);
  }
  catch (NoSuchAlgorithmException nsae) { throw new RuntimeException(nsae); }

Here, I&#039;ve _explicitly_ specified my message digest, and since I&#039;m not planning on distributing this, but only running it on our public webserver, I&#039;m never going to be running it where the security manager _doesn&#039;t_ have MD5 sum. Yet, no, _maybe_ somehow mysteriously MD5 will be missing, so I guess I better catch that... But, that&#039;s not as bad as this next one.

  try {   
    URL u = new URL(&quot;http://www.yahoo.com/&quot;);
  }       
  catch (MalformedURLException mue) { throw new RuntimeException(mue); }

That URL is _static_. Maybe I&#039;m retrieving a feed from somewhere, I don&#039;t know. But, the URL is _unchanging_, and is _not_ dependent on any user input. _WHY_ must I catch &quot;malformed url exception&quot;?? What am I to do with it? I guess I&#039;m protecting myself if the URL spec changes in the future?

I&#039;m with Squirrel up there. For the most part, if an exception is thrown, I really can&#039;t do anything about it, and all that the mandatory checked exceptions get me, is code bloat/cruft.</description>
		<content:encoded><![CDATA[<p>OK, here are my examples, that immediately come to mind. There are a lot more of these, that I know I have to deal with on a continuous basis: exceptions that are _practically_ impossible.</p>
<p>  try {<br />
    MessageDigest md = MessageDigest.getInstance(&#8220;MD5&#8243;);<br />
  }<br />
  catch (NoSuchAlgorithmException nsae) { throw new RuntimeException(nsae); }</p>
<p>Here, I&#8217;ve _explicitly_ specified my message digest, and since I&#8217;m not planning on distributing this, but only running it on our public webserver, I&#8217;m never going to be running it where the security manager _doesn&#8217;t_ have MD5 sum. Yet, no, _maybe_ somehow mysteriously MD5 will be missing, so I guess I better catch that&#8230; But, that&#8217;s not as bad as this next one.</p>
<p>  try {<br />
    URL u = new URL(&#8220;http://www.yahoo.com/&#8221;);<br />
  }<br />
  catch (MalformedURLException mue) { throw new RuntimeException(mue); }</p>
<p>That URL is _static_. Maybe I&#8217;m retrieving a feed from somewhere, I don&#8217;t know. But, the URL is _unchanging_, and is _not_ dependent on any user input. _WHY_ must I catch &#8220;malformed url exception&#8221;?? What am I to do with it? I guess I&#8217;m protecting myself if the URL spec changes in the future?</p>
<p>I&#8217;m with Squirrel up there. For the most part, if an exception is thrown, I really can&#8217;t do anything about it, and all that the mandatory checked exceptions get me, is code bloat/cruft.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-218859</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Mon, 31 May 2010 20:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-218859</guid>
		<description>&gt;&gt; You need well-designed APIs and good programmers to get quality software, whether you are using checked exceptions or not.

The above argument works against the need for checked exceptions as well. Afterall, you need good programmers and good APIs thus there is no need for language level things like checked exceptions to protect you from bad designs and programmers.

This argument holds no weight in the real world where no API is perfect and no programmer is either.</description>
		<content:encoded><![CDATA[<p>&gt;&gt; You need well-designed APIs and good programmers to get quality software, whether you are using checked exceptions or not.</p>
<p>The above argument works against the need for checked exceptions as well. Afterall, you need good programmers and good APIs thus there is no need for language level things like checked exceptions to protect you from bad designs and programmers.</p>
<p>This argument holds no weight in the real world where no API is perfect and no programmer is either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hugo</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-59481</link>
		<dc:creator>Hugo</dc:creator>
		<pubDate>Tue, 18 Mar 2008 14:36:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-59481</guid>
		<description>Hi Squirrel 
about the awful stack traces due to runtime exceptions: you might like have a look at http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.UncaughtExceptionHandler.html 
and Thread.setDefaultUncaughtExceptionHandler(....)

These provide a way to handle runtime exceptions in a custom way (file logging, dialog, etc...).</description>
		<content:encoded><![CDATA[<p>Hi Squirrel<br />
about the awful stack traces due to runtime exceptions: you might like have a look at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.UncaughtExceptionHandler.html" rel="nofollow">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.UncaughtExceptionHandler.html</a><br />
and Thread.setDefaultUncaughtExceptionHandler(&#8230;.)</p>
<p>These provide a way to handle runtime exceptions in a custom way (file logging, dialog, etc&#8230;).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter lawrey</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-58764</link>
		<dc:creator>peter lawrey</dc:creator>
		<pubDate>Wed, 12 Mar 2008 21:59:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-58764</guid>
		<description>Given that methods deprecated in Java 1 are still there today do make removing checked exceptions rather unlikely.
You could have all your method &quot;throws Exception&quot; and ignore them completely if you want to treat them as fatal or ignored at random. 
I am not one of them. :)</description>
		<content:encoded><![CDATA[<p>Given that methods deprecated in Java 1 are still there today do make removing checked exceptions rather unlikely.<br />
You could have all your method &#8220;throws Exception&#8221; and ignore them completely if you want to treat them as fatal or ignored at random.<br />
I am not one of them. <img src='http://www.alittlemadness.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter lawrey</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-58763</link>
		<dc:creator>peter lawrey</dc:creator>
		<pubDate>Wed, 12 Mar 2008 21:55:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-58763</guid>
		<description>Checked Exception have there place. When designing an API I rause checked exceptions when I expect the caller to handle them.  I err on the side of not creating too many variations of checked exceptions so the caller can catch them fairly genericly but still hold enough information to do something about it.
Generally, I would say the callee should try to handle recoverable exceptions however there is often a human involved and notifying them that an operation has failed is important.
Developers typically start by just trying to get something which works, getting something which robustly handles error conditions (assuming you know all possible error conditions) is much harder.
For those who like rapid prototyping I can understand that checked exceptions are annoying, in which case something like groovy or ruby might be a better choice. (I don&#039;t know how their exceptions work...)</description>
		<content:encoded><![CDATA[<p>Checked Exception have there place. When designing an API I rause checked exceptions when I expect the caller to handle them.  I err on the side of not creating too many variations of checked exceptions so the caller can catch them fairly genericly but still hold enough information to do something about it.<br />
Generally, I would say the callee should try to handle recoverable exceptions however there is often a human involved and notifying them that an operation has failed is important.<br />
Developers typically start by just trying to get something which works, getting something which robustly handles error conditions (assuming you know all possible error conditions) is much harder.<br />
For those who like rapid prototyping I can understand that checked exceptions are annoying, in which case something like groovy or ruby might be a better choice. (I don&#8217;t know how their exceptions work&#8230;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Squirrel Sewer</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-58565</link>
		<dc:creator>Squirrel Sewer</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:43:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-58565</guid>
		<description>I think you are fighting the good fight: good error handling is the cornerstone of a maintainable system.  I don&#039;t agree w/ the Effective Java quote, tho.

&quot;Use checked exceptions for recoverable conditions...&quot; 
What percentage of the Exceptions in your code relate to a recoverable conditions?  I maintain a large webapp, and my personal answer is &quot;very few, maybe none&quot;.  I want to handle errors, I really do.

&quot;and runtime exceptions for programming errors&quot;
Runtime Exceptions have a very big problem - they produce awful stack traces.  Checked exceptions, used properly, get caught and wrapped at every level of the call stack, and end up providing all kinds of juicy data when you are reading over the stack.  Why should programming errors have awful stack traces?  They&#039;re way more common than recoverable problems, and just as import to diagnose.

I don&#039;t have any great solutions, just wanted to point out I rarely see opportunities for meaningful recovery, and that I hate stack traces caused by RuntimeExceptions slipping up to the top of the call stack w/ no chaining.</description>
		<content:encoded><![CDATA[<p>I think you are fighting the good fight: good error handling is the cornerstone of a maintainable system.  I don&#8217;t agree w/ the Effective Java quote, tho.</p>
<p>&#8220;Use checked exceptions for recoverable conditions&#8230;&#8221;<br />
What percentage of the Exceptions in your code relate to a recoverable conditions?  I maintain a large webapp, and my personal answer is &#8220;very few, maybe none&#8221;.  I want to handle errors, I really do.</p>
<p>&#8220;and runtime exceptions for programming errors&#8221;<br />
Runtime Exceptions have a very big problem &#8211; they produce awful stack traces.  Checked exceptions, used properly, get caught and wrapped at every level of the call stack, and end up providing all kinds of juicy data when you are reading over the stack.  Why should programming errors have awful stack traces?  They&#8217;re way more common than recoverable problems, and just as import to diagnose.</p>
<p>I don&#8217;t have any great solutions, just wanted to point out I rarely see opportunities for meaningful recovery, and that I hate stack traces caused by RuntimeExceptions slipping up to the top of the call stack w/ no chaining.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-58561</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:18:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-58561</guid>
		<description>Hi Jose,

Thanks for your comment.  You raise a great point about documentation: even with a lot of effort, the docs will still get it wrong.  The only way to get them write is to have them verified automatically - which you get for free with a checked exception.</description>
		<content:encoded><![CDATA[<p>Hi Jose,</p>
<p>Thanks for your comment.  You raise a great point about documentation: even with a lot of effort, the docs will still get it wrong.  The only way to get them write is to have them verified automatically &#8211; which you get for free with a checked exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose</title>
		<link>http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/comment-page-1/#comment-58560</link>
		<dc:creator>Jose</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:15:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-58560</guid>
		<description>C# doesn&#039;t have checked exceptions. While that seems convenient while you&#039;re writing code, the problems become evident later when you realize that you should&#039;ve caught certain exceptions. The documentation is often not very good about this.</description>
		<content:encoded><![CDATA[<p>C# doesn&#8217;t have checked exceptions. While that seems convenient while you&#8217;re writing code, the problems become evident later when you realize that you should&#8217;ve caught certain exceptions. The documentation is often not very good about this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

