<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>danielbunte.de - the actionscripter &#187; TIDY UP YOUR CODE</title>
	<atom:link href="http://danielbunte.de/category/actionscript/tidy-up-your-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielbunte.de</link>
	<description>ActionScript, 3D Flash, AIR</description>
	<lastBuildDate>Tue, 17 Apr 2012 14:30:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>[TIDY UP YOUR CODE] :: if &#8211; elseif &#8211; elseif &#8211; elseif &#8211; else</title>
		<link>http://danielbunte.de/2009/02/06/tidy-up-your-code-if-elseif-elseif-elseif-else/</link>
		<comments>http://danielbunte.de/2009/02/06/tidy-up-your-code-if-elseif-elseif-elseif-else/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 17:20:11 +0000</pubDate>
		<dc:creator>Daniel Bunte</dc:creator>
				<category><![CDATA[TIDY UP YOUR CODE]]></category>

		<guid isPermaLink="false">http://danielbunte.de/?p=67</guid>
		<description><![CDATA[I thought about doing an extra section called &#8216;TIDY UP YOUR CODE&#8217;. From time to time I will post some tips how you can write reader-friendly code. So Let&#8217; start with the first topic: if &#8211; elseif &#8211; elseif &#8211; elseif &#8211; else Have you ever seen something like this ? ActionScriptif&#40;expressionA&#41; &#123; .. do [...]]]></description>
			<content:encoded><![CDATA[<p>I thought about doing an extra section called &#8216;TIDY UP YOUR CODE&#8217;.<br />
From time to time I will post some tips how you can write reader-friendly code.<br />
So Let&#8217; start with the first topic: if &#8211; elseif &#8211; elseif &#8211; elseif &#8211; else</p>
<p>Have you ever seen something like this ?</p>

<div class="wp_syntax_wrapper"><span class="wp_syntax_lang">ActionScript</span><div class="wp_syntax"><div class="code"><pre class="actionscript" style="color: #FFF; font-family:&quot;Consolas&quot;,monospace,&quot;Courier New&quot;"><span style="color: #3D9EDD;">if</span><span style="color: #CCC;">&#40;</span>expressionA<span style="color: #CCC;">&#41;</span>
<span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something ..
<span style="color: #CCC;">&#125;</span>
<span style="color: #3D9EDD;">elseif</span><span style="color: #CCC;">&#40;</span>expressionB<span style="color: #CCC;">&#41;</span>
<span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span>..
<span style="color: #CCC;">&#125;</span>
<span style="color: #3D9EDD;">elseif</span><span style="color: #CCC;">&#40;</span>expressionC<span style="color: #CCC;">&#41;</span>
<span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span>..
<span style="color: #CCC;">&#125;</span>
<span style="color: #3D9EDD;">elseif</span><span style="color: #CCC;">&#40;</span>expressionD<span style="color: #CCC;">&#41;</span>
<span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span>..
<span style="color: #CCC;">&#125;</span>
<span style="color: #3D9EDD;">else</span>
<span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span>..
<span style="color: #CCC;">&#125;</span></pre></div></div></div>

<p>Code like this is hard to read, don&#8217;t you agree with this?<br />
TIDY IT UP! Use a switch instead:</p>

<div class="wp_syntax_wrapper"><span class="wp_syntax_lang">ActionScript</span><div class="wp_syntax"><div class="code"><pre class="actionscript" style="color: #FFF; font-family:&quot;Consolas&quot;,monospace,&quot;Courier New&quot;"><span style="color: #3D9EDD;">switch</span><span style="color: #CCC;">&#40;</span><span style="color: #996600;">true</span><span style="color: #CCC;">&#41;</span>
<span style="color: #CCC;">&#123;</span>
  <span style="color: #3D9EDD;">case</span> expressionA:
  <span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something ..
  <span style="color: #CCC;">&#125;</span>; <span style="color: #3D9EDD;">break</span>;
&nbsp;
  <span style="color: #3D9EDD;">case</span> expressionB:
  <span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span> ..
  <span style="color: #CCC;">&#125;</span>; <span style="color: #3D9EDD;">break</span>;
&nbsp;
  <span style="color: #3D9EDD;">case</span> expressionC:
  <span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span> ..
  <span style="color: #CCC;">&#125;</span>; <span style="color: #3D9EDD;">break</span>;
&nbsp;
  <span style="color: #3D9EDD;">case</span> expressionD:
  <span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span> ..
  <span style="color: #CCC;">&#125;</span>; <span style="color: #3D9EDD;">break</span>;
&nbsp;
  <span style="color: #996600;">default</span>:
  <span style="color: #CCC;">&#123;</span>
  .. <span style="color: #3D9EDD;">do</span> something <span style="color: #3D9EDD;">else</span> ..
  <span style="color: #CCC;">&#125;</span>; <span style="color: #3D9EDD;">break</span>;
<span style="color: #CCC;">&#125;</span></pre></div></div></div>

<p>In my opinion this is great :-}</p>
]]></content:encoded>
			<wfw:commentRss>http://danielbunte.de/2009/02/06/tidy-up-your-code-if-elseif-elseif-elseif-else/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

