<?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: Refactoring Day 18 : Replace exception with conditional</title>
	<atom:link href="http://lostechies.com/seanchambers/2009/08/18/refactoring-day-18-replace-exception-with-conditional/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/seanchambers/2009/08/18/refactoring-day-18-replace-exception-with-conditional/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Thu, 13 Sep 2012 07:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Quick Joe Smith</title>
		<link>http://lostechies.com/seanchambers/2009/08/18/refactoring-day-18-replace-exception-with-conditional/#comment-415</link>
		<dc:creator>Quick Joe Smith</dc:creator>
		<pubDate>Thu, 20 Aug 2009 12:35:52 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2009/08/18/refactoring-day-18-replace-exception-with-conditional.aspx#comment-415</guid>
		<description>Going with the example, it may depend on why the microwave can&#039;t start. It may be in use, it may be broken, it may not be plugged in. Returning false isn&#039;t going to shed much light on the problem. Sometimes just knowing something failed isn&#039;t enough.

Both examples however do just that (return false). Perhaps it is better to combine conditional checking (eg, IsInUse, IsPluggedIn, IsBroken, etc.) with throwing the appropriate exception, enabling calling code to take proper action, such as microwave.PlugIn() or while(microwave.InUse) { Thread.sleep(1000); }.</description>
		<content:encoded><![CDATA[<p>Going with the example, it may depend on why the microwave can&#8217;t start. It may be in use, it may be broken, it may not be plugged in. Returning false isn&#8217;t going to shed much light on the problem. Sometimes just knowing something failed isn&#8217;t enough.</p>
<p>Both examples however do just that (return false). Perhaps it is better to combine conditional checking (eg, IsInUse, IsPluggedIn, IsBroken, etc.) with throwing the appropriate exception, enabling calling code to take proper action, such as microwave.PlugIn() or while(microwave.InUse) { Thread.sleep(1000); }.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eyston</title>
		<link>http://lostechies.com/seanchambers/2009/08/18/refactoring-day-18-replace-exception-with-conditional/#comment-414</link>
		<dc:creator>Eyston</dc:creator>
		<pubDate>Tue, 18 Aug 2009 17:24:31 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2009/08/18/refactoring-day-18-replace-exception-with-conditional.aspx#comment-414</guid>
		<description>Maybe it is just a bad example ... but having to check a boolean result seems very c&#039;ish doesn&#039;t it?

If I call microwave.Start(food) and the microwave can&#039;t do it... is an exception appropriate?  It seems like a message back to the caller on why it can&#039;t start would be useful ... but I don&#039;t know if an exception is an abuse or not (ie it doesn&#039;t seem that exceptional).</description>
		<content:encoded><![CDATA[<p>Maybe it is just a bad example &#8230; but having to check a boolean result seems very c&#8217;ish doesn&#8217;t it?</p>
<p>If I call microwave.Start(food) and the microwave can&#8217;t do it&#8230; is an exception appropriate?  It seems like a message back to the caller on why it can&#8217;t start would be useful &#8230; but I don&#8217;t know if an exception is an abuse or not (ie it doesn&#8217;t seem that exceptional).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob White</title>
		<link>http://lostechies.com/seanchambers/2009/08/18/refactoring-day-18-replace-exception-with-conditional/#comment-413</link>
		<dc:creator>Rob White</dc:creator>
		<pubDate>Tue, 18 Aug 2009 15:34:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/sean_chambers/archive/2009/08/18/refactoring-day-18-replace-exception-with-conditional.aspx#comment-413</guid>
		<description>I think the general idea is sound, but it&#039;s worth noting that this kind of code is vulnerable to race conditions, so the exception may still need to be thrown by Motor.Cook(food)</description>
		<content:encoded><![CDATA[<p>I think the general idea is sound, but it&#8217;s worth noting that this kind of code is vulnerable to race conditions, so the exception may still need to be thrown by Motor.Cook(food)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
