<?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: Keep Java checked exceptions in a bounded context</title>
	<atom:link href="http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: jonnie savell</title>
		<link>http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/comment-page-1/#comment-4802</link>
		<dc:creator>jonnie savell</dc:creator>
		<pubDate>Fri, 23 Jan 2009 01:12:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=533#comment-4802</guid>
		<description>I have no idea whether we are in agreement, but here is what I think.

The exception thrown from methods within a particular library should not affect any code other than the immediate client (as you appear to say). If the methods within this library throw a checked exception, then you can throw a RuntimeException (if you feel that nothing can be done because of the seriousness of the error). All the same, there are times when the client knows better than the library what constitutes an error from which recovery cannot occur.

There is a preferable alternative. Client code can throw its own  checked exception (supplying the checked exception you just caught as the cause). This latter technique forces a cascade of similar  decisions from client to client. I believe that this is the correct technique. The cause information is preserved in the event that one who debugs may find it useful, but the bounded context is kept free from these details in outer scopes.

I like to create checked exceptions in the code I write because I want to do more than inform client code of the nature of the problem when it happens; I want to force client code to statically acknowledge the possibility of it happening exists (by forcing it to catch). Client code may undermine this obligation by rethrowing unchecked exceptions and this is OK. Therefore, the fact that my library throws a checked exception doesn&#039;t deeply upset your client code or its clients.

Well, you don&#039;t appear to argue against my thesis, but you like C# which does insofar as it steals my ability to throw checked exceptions (or maybe it is .NET and not C# which does this, but I don&#039;t care).

This is a theft most worthy of a rant!</description>
		<content:encoded><![CDATA[<p>I have no idea whether we are in agreement, but here is what I think.</p>
<p>The exception thrown from methods within a particular library should not affect any code other than the immediate client (as you appear to say). If the methods within this library throw a checked exception, then you can throw a RuntimeException (if you feel that nothing can be done because of the seriousness of the error). All the same, there are times when the client knows better than the library what constitutes an error from which recovery cannot occur.</p>
<p>There is a preferable alternative. Client code can throw its own  checked exception (supplying the checked exception you just caught as the cause). This latter technique forces a cascade of similar  decisions from client to client. I believe that this is the correct technique. The cause information is preserved in the event that one who debugs may find it useful, but the bounded context is kept free from these details in outer scopes.</p>
<p>I like to create checked exceptions in the code I write because I want to do more than inform client code of the nature of the problem when it happens; I want to force client code to statically acknowledge the possibility of it happening exists (by forcing it to catch). Client code may undermine this obligation by rethrowing unchecked exceptions and this is OK. Therefore, the fact that my library throws a checked exception doesn&#8217;t deeply upset your client code or its clients.</p>
<p>Well, you don&#8217;t appear to argue against my thesis, but you like C# which does insofar as it steals my ability to throw checked exceptions (or maybe it is .NET and not C# which does this, but I don&#8217;t care).</p>
<p>This is a theft most worthy of a rant!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Testing Hibernate mappings: Testing Equality at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/comment-page-1/#comment-993</link>
		<dc:creator>Testing Hibernate mappings: Testing Equality at Mark Needham</dc:creator>
		<pubDate>Thu, 30 Oct 2008 12:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=533#comment-993</guid>
		<description>[...] I ran into the example dilemma a bit while writing this but hopefully the ideas have been expressed in the code presented. I didn&#039;t want to put too much code in this post but if you&#039;re interested in what the OgnlWrapper does I posted more about this on my post about Java checked exceptions. [...]</description>
		<content:encoded><![CDATA[<p>[...] I ran into the example dilemma a bit while writing this but hopefully the ideas have been expressed in the code presented. I didn&#8217;t want to put too much code in this post but if you&#8217;re interested in what the OgnlWrapper does I posted more about this on my post about Java checked exceptions. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/comment-page-1/#comment-904</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Fri, 24 Oct 2008 12:27:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=533#comment-904</guid>
		<description>This is true and I think your idea of wrapping these exceptions with Environment Exception is better than the example I&#039;ve provided.

I was more saying it&#039;s better not to bubble up Checked Exceptions like the OgnlException up our code since classes further away don&#039;t actually care about that specific error. In this example they would just care that there was a problem building Foo.</description>
		<content:encoded><![CDATA[<p>This is true and I think your idea of wrapping these exceptions with Environment Exception is better than the example I&#8217;ve provided.</p>
<p>I was more saying it&#8217;s better not to bubble up Checked Exceptions like the OgnlException up our code since classes further away don&#8217;t actually care about that specific error. In this example they would just care that there was a problem building Foo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren Hobbs</title>
		<link>http://www.markhneedham.com/blog/2008/10/23/keep-java-checked-exceptions-in-a-bounded-context/comment-page-1/#comment-898</link>
		<dc:creator>Darren Hobbs</dc:creator>
		<pubDate>Fri, 24 Oct 2008 09:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=533#comment-898</guid>
		<description>Wrapping a checked exception in a RuntimeException does not make it cease to exist! Or perhaps I misunderstood. I have recently learned how to stop worrying and love checked exceptions. There is a simple rule for happy exception handling. If something can be reasonably expected to fail and needs to be dealt with, throw a checked exception Good examples are IO and network issues. (We have a class called EnvironmentException that we wrap all exceptions of this category in). All other exceptions are bugs. I recommend creating a class Defect that extends RuntimeException and using it to wrap all exceptions that can ONLY occur due to programmer error. Then it&#039;s easy to have a top-level catch block to report the problem.</description>
		<content:encoded><![CDATA[<p>Wrapping a checked exception in a RuntimeException does not make it cease to exist! Or perhaps I misunderstood. I have recently learned how to stop worrying and love checked exceptions. There is a simple rule for happy exception handling. If something can be reasonably expected to fail and needs to be dealt with, throw a checked exception Good examples are IO and network issues. (We have a class called EnvironmentException that we wrap all exceptions of this category in). All other exceptions are bugs. I recommend creating a class Defect that extends RuntimeException and using it to wrap all exceptions that can ONLY occur due to programmer error. Then it&#8217;s easy to have a top-level catch block to report the problem.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

