<?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: Programming Style: Two Booleans, Three Possible Cases</title>
	<atom:link href="http://jxpx777.com/all/programming-style-two-booleans-three-possible-cases/feed" rel="self" type="application/rss+xml" />
	<link>http://jxpx777.com/blog/programming-style-two-booleans-three-possible-cases</link>
	<description>Proving the sunshine since 1980.</description>
	<lastBuildDate>Fri, 15 Jul 2011 00:24:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: David A Teare</title>
		<link>http://jxpx777.com/blog/programming-style-two-booleans-three-possible-cases#comment-1390</link>
		<dc:creator>David A Teare</dc:creator>
		<pubDate>Sat, 27 Sep 2008 04:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-1390</guid>
		<description>&lt;p&gt;If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &quot;do bar-only stuff&quot;, which is false.&lt;/p&gt;

&lt;p&gt;I think you needed an extra &#039;else if&#039; clause.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &#8220;do bar-only stuff&#8221;, which is false.</p>

<p>I think you needed an extra &#8216;else if&#8217; clause.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: David A Teare</title>
		<link>http://jxpx777.com/blog/programming-style-two-booleans-three-possible-cases#comment-119</link>
		<dc:creator>David A Teare</dc:creator>
		<pubDate>Fri, 26 Sep 2008 23:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-119</guid>
		<description>&lt;p&gt;If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &quot;do bar-only stuff&quot;, which is false.&lt;/p&gt;

&lt;p&gt;I think you needed an extra &#039;else if&#039; clause.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &#8220;do bar-only stuff&#8221;, which is false.</p>

<p>I think you needed an extra &#8216;else if&#8217; clause.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Hughes</title>
		<link>http://jxpx777.com/blog/programming-style-two-booleans-three-possible-cases#comment-1391</link>
		<dc:creator>Mark Hughes</dc:creator>
		<pubDate>Thu, 25 Sep 2008 19:27:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-1391</guid>
		<description>&lt;p&gt;If foo and bar are set by logically related tests, there&#039;s likely some common value you can use for them both. Lacking that common value, I&#039;d do this:&lt;/p&gt;

&lt;p&gt;NSInteger choice = (foo ? 1 : 0) &#124; (bar ? 2 : 0);&lt;br /&gt;switch (choice) {&lt;br /&gt;  case 0:&lt;br /&gt;    // nothing&lt;br /&gt;    break;&lt;br /&gt;  case 1:&lt;br /&gt;    // foo&lt;br /&gt;    break;&lt;br /&gt;  case 2:&lt;br /&gt;    // bar&lt;br /&gt;    break;&lt;br /&gt;  case 3:&lt;br /&gt;    // foo and bar&lt;br /&gt;    break;&lt;br /&gt;  default:&lt;br /&gt;    NSAssert1(NO, @&quot;Invalid choice %d&quot;, choice);&lt;br /&gt;}&lt;/p&gt;

&lt;p&gt;This makes it instantly clear that I&#039;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo and bar are set by logically related tests, there&#8217;s likely some common value you can use for them both. Lacking that common value, I&#8217;d do this:</p>

<p>NSInteger choice = (foo ? 1 : 0) | (bar ? 2 : 0);<br />switch (choice) {<br />  case 0:<br />    // nothing<br />    break;<br />  case 1:<br />    // foo<br />    break;<br />  case 2:<br />    // bar<br />    break;<br />  case 3:<br />    // foo and bar<br />    break;<br />  default:<br />    NSAssert1(NO, @&#8221;Invalid choice %d&#8221;, choice);<br />}</p>

<p>This makes it instantly clear that I&#8217;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Hughes</title>
		<link>http://jxpx777.com/blog/programming-style-two-booleans-three-possible-cases#comment-117</link>
		<dc:creator>Mark Hughes</dc:creator>
		<pubDate>Thu, 25 Sep 2008 14:27:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-117</guid>
		<description>&lt;p&gt;If foo and bar are set by logically related tests, there&#039;s likely some common value you can use for them both. Lacking that common value, I&#039;d do this:&lt;/p&gt;

&lt;p&gt;NSInteger choice = (foo ? 1 : 0) &#124; (bar ? 2 : 0);
switch (choice) {
  case 0:
    // nothing
    break;
  case 1:
    // foo
    break;
  case 2:
    // bar
    break;
  case 3:
    // foo and bar
    break;
  default:
    NSAssert1(NO, @&quot;Invalid choice %d&quot;, choice);
}&lt;/p&gt;

&lt;p&gt;This makes it instantly clear that I&#039;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo and bar are set by logically related tests, there&#8217;s likely some common value you can use for them both. Lacking that common value, I&#8217;d do this:</p>

<p>NSInteger choice = (foo ? 1 : 0) | (bar ? 2 : 0);
switch (choice) {
  case 0:
    // nothing
    break;
  case 1:
    // foo
    break;
  case 2:
    // bar
    break;
  case 3:
    // foo and bar
    break;
  default:
    NSAssert1(NO, @&#8221;Invalid choice %d&#8221;, choice);
}</p>

<p>This makes it instantly clear that I&#8217;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.</p>]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: jxpx777.com @ 2012-02-17 12:29:08 -->
