<?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: Why not use Exceptions to Control Flow ?</title>
	<atom:link href="http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/feed" rel="self" type="application/rss+xml" />
	<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 18:56:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Kumar Reddy TCS</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-49</link>
		<dc:creator>Kumar Reddy TCS</dc:creator>
		<pubDate>Thu, 09 Jun 2005 02:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-49</guid>
		<description>This is reply to &quot;you meant to say, &quot;throws Exception&#039; is a bad idea&quot;.

Yes, I Believe, there are a lot of ways, where one can use conditions to control the flow. And throwing exceptions to control the flow in a program is really a bad idea.
</description>
		<content:encoded><![CDATA[<p>This is reply to &#8220;you meant to say, &#8220;throws Exception&#8217; is a bad idea&#8221;.</p>
<p>Yes, I Believe, there are a lot of ways, where one can use conditions to control the flow. And throwing exceptions to control the flow in a program is really a bad idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bitter</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-48</link>
		<dc:creator>Bitter</dc:creator>
		<pubDate>Tue, 03 May 2005 17:03:08 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-48</guid>
		<description>I think you meant to say &quot;&#039;throws Exception&#039; is a bad idea&quot;.

Surely.
</description>
		<content:encoded><![CDATA[<p>I think you meant to say &#8220;&#8216;throws Exception&#8217; is a bad idea&#8221;.</p>
<p>Surely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will Sargent</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-47</link>
		<dc:creator>Will Sargent</dc:creator>
		<pubDate>Tue, 03 May 2005 11:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-47</guid>
		<description>Throwing an exception is an expensive operation in java compared to a break, continue or return.  In the situation you give as an example, it&#039;s actually an appropriate behaviour, assuming that the method defines SomeException in the interface.

In the situation where it&#039;s a run time exception, you catch the exception and then throw it again:
[code]
private String getSomething() throws SomeException
{
String s;
try {
s = doSomething();
}
catch(SomeException se) {
s = doSomethingElse();
throw se;
}
}[/code]

So that your special error handling behaviour goes through.  Maybe there should be a fillInStackTrace() in there, I forget.
</description>
		<content:encoded><![CDATA[<p>Throwing an exception is an expensive operation in java compared to a break, continue or return.  In the situation you give as an example, it&#8217;s actually an appropriate behaviour, assuming that the method defines SomeException in the interface.</p>
<p>In the situation where it&#8217;s a run time exception, you catch the exception and then throw it again:<br />
[code]<br />
private String getSomething() throws SomeException<br />
{<br />
String s;<br />
try {<br />
s = doSomething();<br />
}<br />
catch(SomeException se) {<br />
s = doSomethingElse();<br />
throw se;<br />
}<br />
}[/code]</p>
<p>So that your special error handling behaviour goes through.  Maybe there should be a fillInStackTrace() in there, I forget.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subbu Allamaraju</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-46</link>
		<dc:creator>Subbu Allamaraju</dc:creator>
		<pubDate>Tue, 03 May 2005 07:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-46</guid>
		<description>&lt;p&gt;This is a reply to the comment &quot;How does this make the code fragile? There are times when you need to do this&quot;.&lt;/p&gt;

&lt;p&gt;There are better ways to control the flow of execution without using exceptions. A simple &quot;if/else&quot; could be used to make such choices. Exceptions are for exceptions, and the catch block is for recovering from exceptions, but not to make algorithmic choices. When such choices are make via exceptions, code could become fragile.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This is a reply to the comment &#8220;How does this make the code fragile? There are times when you need to do this&#8221;.</p>
<p>There are better ways to control the flow of execution without using exceptions. A simple &#8220;if/else&#8221; could be used to make such choices. Exceptions are for exceptions, and the catch block is for recovering from exceptions, but not to make algorithmic choices. When such choices are make via exceptions, code could become fragile.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: afdsfdas</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-45</link>
		<dc:creator>afdsfdas</dc:creator>
		<pubDate>Tue, 03 May 2005 07:34:12 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-45</guid>
		<description>How does this make the code fragile?  There are times when you need to do this.

If doSomething fails, you need to record that it happened.

In your mind, are you supposed to catch exceptions, then ignore them?  That is much much worse.
</description>
		<content:encoded><![CDATA[<p>How does this make the code fragile?  There are times when you need to do this.</p>
<p>If doSomething fails, you need to record that it happened.</p>
<p>In your mind, are you supposed to catch exceptions, then ignore them?  That is much much worse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Copeland</title>
		<link>http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow/comment-page-1#comment-44</link>
		<dc:creator>Tom Copeland</dc:creator>
		<pubDate>Tue, 03 May 2005 07:33:45 +0000</pubDate>
		<guid isPermaLink="false">http://wp.subbu.org/2005/05/why-not-use-exceptions-to-control-flow/#comment-44</guid>
		<description>PMD has a rule which checks for this - ExceptionAsFlowControl:
&lt;br /&gt;&lt;a href=&quot;http://pmd.sourceforge.net/rules/strictexception.html&quot; rel=&quot;nofollow&quot;&gt;&lt;a href=&quot;http://pmd.sourceforge.net/rules/strictexception.html&quot; rel=&quot;nofollow&quot;&gt;http://pmd.sourceforge.net/rules/strictexception.html&lt;/a&gt;&lt;/a&gt;
</description>
		<content:encoded><![CDATA[<p>PMD has a rule which checks for this &#8211; ExceptionAsFlowControl:<br />
<br /><a href="http://pmd.sourceforge.net/rules/strictexception.html" rel="nofollow"></a><a href="http://pmd.sourceforge.net/rules/strictexception.html" rel="nofollow">http://pmd.sourceforge.net/rules/strictexception.html</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

