<?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: Code idiom: using logical ^ to change your mind</title>
	<atom:link href="http://madbean.com/2003/mb2003-14/feed/" rel="self" type="application/rss+xml" />
	<link>http://madbean.com/2003/mb2003-14/</link>
	<description>The other kind of micro blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 22:23:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Will Sargent</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-30</link>
		<dc:creator>Will Sargent</dc:creator>
		<pubDate>Fri, 12 Sep 2003 17:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-30</guid>
		<description>&lt;p&gt;Just plain evil.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Just plain evil.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous Coward</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-29</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Fri, 08 Aug 2003 21:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-29</guid>
		<description>&lt;p&gt;too clever by half.
..at least.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>too clever by half.<br />
..at least.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Greer</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-28</link>
		<dc:creator>Kevin Greer</dc:creator>
		<pubDate>Thu, 05 Jun 2003 13:49:58 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-28</guid>
		<description>&lt;p&gt;Or just:
&lt;code&gt;
return result != invert;
&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Or just:<br />
<code><br />
return result != invert;<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Greer</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-27</link>
		<dc:creator>Kevin Greer</dc:creator>
		<pubDate>Thu, 05 Jun 2003 13:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-27</guid>
		<description>&lt;p&gt;You could also do:
&lt;code&gt;
return result == ! invert;
&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You could also do:<br />
<code><br />
return result == ! invert;<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Burn</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-26</link>
		<dc:creator>Oliver Burn</dc:creator>
		<pubDate>Mon, 31 Mar 2003 09:49:06 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-26</guid>
		<description>&lt;p&gt;While I agree with you Brendan, I would redo your example as:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
final boolean result = evaluateCondition();
return (invert) ? !result : result;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I find this approach improves code coverage and is easier to read. &gt;:)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>While I agree with you Brendan, I would redo your example as:</p>
<p><code><br />
final boolean result = evaluateCondition();<br />
return (invert) ? !result : result;<br />
</code></p>
<p>I find this approach improves code coverage and is easier to read. &gt;:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Humphreys</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-25</link>
		<dc:creator>Brendan Humphreys</dc:creator>
		<pubDate>Mon, 31 Mar 2003 03:41:39 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-25</guid>
		<description>&lt;p&gt;Matt wrote:
&lt;code&gt;
This idiom is a cool little trick, but I&#039;ve seen coders scratching their head trying to work out what it does; so a detailed explanation is in order. 
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I think the fact that coders are scratching their heads makes this more of a &quot;trick&quot; and less of an &quot;idiom&quot;. That you leave coders puzzled is enough of a reason not to use it, since it doesn&#039;t really buy you much, and the readability of the code is reduced.     &lt;/p&gt;

&lt;p&gt;For me, I&#039;d prefer to see it spelt out: 
&lt;code&gt;
boolean result = evaluateCondition();&lt;/p&gt;

&lt;p&gt;if (invert) {
   result = !result;
}
return result;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sure it&#039;s a bit more typing, but it doesn&#039;t require the audience to have a knowledge of an arguably obscure language feature. When running the latter chunk thru my wetware language parser, it reads quickly and elegantly.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Matt wrote:<br />
<code><br />
This idiom is a cool little trick, but I've seen coders scratching their head trying to work out what it does; so a detailed explanation is in order.<br />
</code></p>
<p>I think the fact that coders are scratching their heads makes this more of a &quot;trick&quot; and less of an &quot;idiom&quot;. That you leave coders puzzled is enough of a reason not to use it, since it doesn&#8217;t really buy you much, and the readability of the code is reduced.     </p>
<p>For me, I&#8217;d prefer to see it spelt out:<br />
<code><br />
boolean result = evaluateCondition();</code></p>
<p>if (invert) {<br />
   result = !result;<br />
}<br />
return result;
</p>
<p>Sure it&#8217;s a bit more typing, but it doesn&#8217;t require the audience to have a knowledge of an arguably obscure language feature. When running the latter chunk thru my wetware language parser, it reads quickly and elegantly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Burn</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-24</link>
		<dc:creator>Oliver Burn</dc:creator>
		<pubDate>Thu, 27 Mar 2003 09:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-24</guid>
		<description>&lt;p&gt;You made me :? quite hard with this one, but I am now :-D&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You made me :? quite hard with this one, but I am now <img src='http://madbean.com/wp-content/plugins/smilies-themer/adiumicons/biggrin.png' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Green</title>
		<link>http://madbean.com/2003/mb2003-14/comment-page-1/#comment-23</link>
		<dc:creator>Alan Green</dc:creator>
		<pubDate>Wed, 26 Mar 2003 19:56:18 +0000</pubDate>
		<guid isPermaLink="false">http://madbean.com/blog/2003-14#comment-23</guid>
		<description>&lt;p&gt;I&#039;ve recently saw a pair of conditional tags &lt;IsNull&gt; and &lt;IsNotNull&gt; implemented with an abstract base class that has the method: 
&lt;code&gt;
    protected abstract boolean isNullAGoodThing()
&lt;/code&gt;
Each tag is implemented with a very short subclass, one implementing this method as &quot;return true&quot;, and the other &quot;return false&quot;. I&#039;ll have a look at that code again and see if I could replace it with a single class using &#039;^&#039;.&lt;/p&gt;

&lt;p&gt;Alan&lt;/p&gt;

&lt;p&gt;PS: Your smileys are just too cute :D&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve recently saw a pair of conditional tags &lt;IsNull&gt; and &lt;IsNotNull&gt; implemented with an abstract base class that has the method:<br />
<code><br />
    protected abstract boolean isNullAGoodThing()<br />
</code><br />
Each tag is implemented with a very short subclass, one implementing this method as &quot;return true&quot;, and the other &quot;return false&quot;. I&#8217;ll have a look at that code again and see if I could replace it with a single class using &#8216;^&#8217;.</p>
<p>Alan</p>
<p>PS: Your smileys are just too cute <img src='http://madbean.com/wp-content/plugins/smilies-themer/adiumicons/biggrin.png' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

