<?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: I&#8217;d Rather switch Than Fight!</title>
	<atom:link href="http://www.yuiblog.com/blog/index.php/2007/04/25/id-rather-switch-than-fight/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/</link>
	<description>The official blog of the YUI Project.</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:46:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Martijn Laarman</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-322158</link>
		<dc:creator>Martijn Laarman</dc:creator>
		<pubDate>Thu, 13 Mar 2008 17:33:20 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-322158</guid>
		<description>I only use switch&#039;s fallthrough for grouping 
&lt;code&gt;
switch(i) 
{
       case 3:
       case 6:
              dosomething()
              break;
       case 1:
       case 4:
              doSomethingElse();
              break;
       default:
              doSomethingElseAllTogether()
}
&lt;/code&gt;

In such cases the fallthrough is easy to pick up and very a sementical solution.

When 3 needs to do somethingOdd() and doSomething() and 6 only needs to doSomething() i generally avoid, and thus agree with the artice, the usage of switch.</description>
		<content:encoded><![CDATA[<p>I only use switch&#8217;s fallthrough for grouping<br />
<code><br />
switch(i)<br />
{<br />
       case 3:<br />
       case 6:<br />
              dosomething()<br />
              break;<br />
       case 1:<br />
       case 4:<br />
              doSomethingElse();<br />
              break;<br />
       default:<br />
              doSomethingElseAllTogether()<br />
}<br />
</code></p>
<p>In such cases the fallthrough is easy to pick up and very a sementical solution.</p>
<p>When 3 needs to do somethingOdd() and doSomething() and 6 only needs to doSomething() i generally avoid, and thus agree with the artice, the usage of switch.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Jones</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-190088</link>
		<dc:creator>David Jones</dc:creator>
		<pubDate>Thu, 13 Sep 2007 13:29:24 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-190088</guid>
		<description>Ted, I&#039;m not sure about fall through being switch&#039;s &quot;cleverest feature&quot;, but it could be a reference to &lt;a href=&quot;http://groups.google.com/group/net.lang.c/msg/66008138e07aa94c&quot; rel=&quot;nofollow&quot;&gt;Duff&#039;s device&lt;/a&gt;.

JavaScript saw fit to change switch (compared to the C version) by not allowing the case statements to be embedded in interior statements (as in Duff&#039;s device), but mysteriously didn&#039;t take to opportunity to remove fall through.  Strange.

switch in JavaScript has another &quot;attractive nuisance&quot; too (love the term).  You can have non constant expressions in the case labels.  Happily &lt;a href=&quot;http://drj11.wordpress.com/2007/09/03/javascript-switch/&quot; rel=&quot;nofollow&quot;&gt;I seem to be the only one to have noticed that&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Ted, I&#8217;m not sure about fall through being switch&#8217;s &#8220;cleverest feature&#8221;, but it could be a reference to <a href="http://groups.google.com/group/net.lang.c/msg/66008138e07aa94c" rel="nofollow">Duff&#8217;s device</a>.</p>
<p>JavaScript saw fit to change switch (compared to the C version) by not allowing the case statements to be embedded in interior statements (as in Duff&#8217;s device), but mysteriously didn&#8217;t take to opportunity to remove fall through.  Strange.</p>
<p>switch in JavaScript has another &#8220;attractive nuisance&#8221; too (love the term).  You can have non constant expressions in the case labels.  Happily <a href="http://drj11.wordpress.com/2007/09/03/javascript-switch/" rel="nofollow">I seem to be the only one to have noticed that</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordan</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-107358</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Tue, 08 May 2007 08:16:04 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-107358</guid>
		<description>What if the &quot;break&quot; statement was on the same line as &quot;case.&quot; Would that make it more obvious?

switch(arg) {
  case &quot;&quot;:

  break; case &quot;&quot;:

  break; case &quot;&quot;:

  break; case &quot;&quot;:

  case &quot;&quot;:

  break; case &quot;&quot;:
}</description>
		<content:encoded><![CDATA[<p>What if the &#8220;break&#8221; statement was on the same line as &#8220;case.&#8221; Would that make it more obvious?</p>
<p>switch(arg) {<br />
  case &#8220;&#8221;:</p>
<p>  break; case &#8220;&#8221;:</p>
<p>  break; case &#8220;&#8221;:</p>
<p>  break; case &#8220;&#8221;:</p>
<p>  case &#8220;&#8221;:</p>
<p>  break; case &#8220;&#8221;:<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dustin Diaz</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-105104</link>
		<dc:creator>Dustin Diaz</dc:creator>
		<pubDate>Sat, 05 May 2007 02:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-105104</guid>
		<description>I actually liked goto. It made looping easy in QBasic. Doesn&#039;t ActionScript also have the notion of goto?</description>
		<content:encoded><![CDATA[<p>I actually liked goto. It made looping easy in QBasic. Doesn&#8217;t ActionScript also have the notion of goto?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: romiro</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-104131</link>
		<dc:creator>romiro</dc:creator>
		<pubDate>Thu, 03 May 2007 22:57:03 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-104131</guid>
		<description>I always thought there was something fishy about that switch statement...I always felt dirty using it and never exactly could put my finger on it.</description>
		<content:encoded><![CDATA[<p>I always thought there was something fishy about that switch statement&#8230;I always felt dirty using it and never exactly could put my finger on it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-102694</link>
		<dc:creator>Lars</dc:creator>
		<pubDate>Mon, 30 Apr 2007 23:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-102694</guid>
		<description>Since the fallthru is the exception rather then the rule, the &#039;break&#039; in each case should be assumed and a &#039;fallthru&#039; command used to explicitly break the rule (no pun intended). However it is dificult to retrospectively correct for poor design.</description>
		<content:encoded><![CDATA[<p>Since the fallthru is the exception rather then the rule, the &#8216;break&#8217; in each case should be assumed and a &#8216;fallthru&#8217; command used to explicitly break the rule (no pun intended). However it is dificult to retrospectively correct for poor design.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-102632</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Mon, 30 Apr 2007 20:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-102632</guid>
		<description>&lt;i&gt;GOTO is evil because it allows you to get away with hairy coding&lt;/i&gt;

The hairy code I&#039;m talking about is not something that&#039;s &quot;gotten away with,&quot; but a result of an evolutionary process, of years of modification by a multitude of programmers given a myriad of requirements under many time constraints. You know, the real world.

And I compared GOTO to labeled breaks, which don&#039;t all go to the same place.</description>
		<content:encoded><![CDATA[<p><i>GOTO is evil because it allows you to get away with hairy coding</i></p>
<p>The hairy code I&#8217;m talking about is not something that&#8217;s &#8220;gotten away with,&#8221; but a result of an evolutionary process, of years of modification by a multitude of programmers given a myriad of requirements under many time constraints. You know, the real world.</p>
<p>And I compared GOTO to labeled breaks, which don&#8217;t all go to the same place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: johnnysaucepn</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-102427</link>
		<dc:creator>johnnysaucepn</dc:creator>
		<pubDate>Mon, 30 Apr 2007 09:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-102427</guid>
		<description>&lt;blockquote cite=&quot;Brad&quot;&gt;Whether the code should be refactored to eliminate the hairy nest is another issue altogether.&lt;/blockquote&gt;

Actually, it&#039;s the same issue! GOTO is evil because it allows you to get away with hairy coding, and makes it even hairier. I&#039;m no fan of &lt;em&gt;switch/break/fallthrough&lt;/em&gt;, but at least the break doesn&#039;t have to specify where to go next - all breaks go to the same place.</description>
		<content:encoded><![CDATA[<blockquote cite="Brad"><p>Whether the code should be refactored to eliminate the hairy nest is another issue altogether.</p></blockquote>
<p>Actually, it&#8217;s the same issue! GOTO is evil because it allows you to get away with hairy coding, and makes it even hairier. I&#8217;m no fan of <em>switch/break/fallthrough</em>, but at least the break doesn&#8217;t have to specify where to go next &#8211; all breaks go to the same place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-102042</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Sun, 29 Apr 2007 15:02:58 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-102042</guid>
		<description>As an old Fortan guy, let me put in a good word for GOTO. Forgetting for a second that it&#039;s just a branch statement, and that no matter the language all loop and if/switch/case/whatever statements get compiled down to branches, sometimes jumping out of  hairy nested constructs is easier to figure out with a GOTO than with a series of labeled break statements. (Whether the code should be refactored to eliminate the hairy nest is another issue altogether.)

However, a computed GOTO really is evil.</description>
		<content:encoded><![CDATA[<p>As an old Fortan guy, let me put in a good word for GOTO. Forgetting for a second that it&#8217;s just a branch statement, and that no matter the language all loop and if/switch/case/whatever statements get compiled down to branches, sometimes jumping out of  hairy nested constructs is easier to figure out with a GOTO than with a series of labeled break statements. (Whether the code should be refactored to eliminate the hairy nest is another issue altogether.)</p>
<p>However, a computed GOTO really is evil.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/comment-page-1/#comment-100886</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Fri, 27 Apr 2007 15:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/#comment-100886</guid>
		<description>The case you list is very useful and not bug-prone. It&#039;s when there are lines of code but no break in between cases that things can get really tricky. Some languages (I&#039;m pretty sure C# and Java do this) allow for your case while disallowing the general, tricky case.</description>
		<content:encoded><![CDATA[<p>The case you list is very useful and not bug-prone. It&#8217;s when there are lines of code but no break in between cases that things can get really tricky. Some languages (I&#8217;m pretty sure C# and Java do this) allow for your case while disallowing the general, tricky case.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

