<?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: &#8220;Don&#8217;t Make Me Think&#8221; applies to your code, too</title>
	<atom:link href="http://blog.markturansky.com/archives/70/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.markturansky.com/archives/70</link>
	<description>software architecture &#38; engineering, code hints, sometimes philosophy, photography, life, etc.</description>
	<lastBuildDate>Thu, 19 Jan 2012 14:26:50 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Taylor Gautier</title>
		<link>http://blog.markturansky.com/archives/70/comment-page-1#comment-719</link>
		<dc:creator>Taylor Gautier</dc:creator>
		<pubDate>Tue, 06 May 2008 17:17:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/70#comment-719</guid>
		<description>DAR

Agree with Mark and Dimitre.  Too much thinking required to figure out what the hell is going on in nested ternary statements.  You&#039;re trying to be too clever for your own good, and I guarantee you something will go wrong with your code down the line.  And probably not because you broke it.  But because someone else didn&#039;t understand what your statement is doing.  Computers are fast.  Don&#039;t worry about optimizing a few lines of code for the computer - optimize for the human reading it.

Generally I&#039;d say you really missed the whole point of Mark&#039;s post.  It&#039;s not about making the computer do the right thing.  That&#039;s easy.  The hard part is helping humans understand what is happening.  Nested ternary statements fail the latter.  ALWAYS.  

In fact, to add to Mark&#039;s general rule of thumb - I will just go ahead and say never nest statements more than one level deep.  You&#039;ve done something wrong if you need that level of complexity.  Break it down.  Simplify it - and write for the junior level coder that will be maintaining your code after you are long gone sipping margaritas on the beach.</description>
		<content:encoded><![CDATA[<p>DAR</p>
<p>Agree with Mark and Dimitre.  Too much thinking required to figure out what the hell is going on in nested ternary statements.  You&#8217;re trying to be too clever for your own good, and I guarantee you something will go wrong with your code down the line.  And probably not because you broke it.  But because someone else didn&#8217;t understand what your statement is doing.  Computers are fast.  Don&#8217;t worry about optimizing a few lines of code for the computer &#8211; optimize for the human reading it.</p>
<p>Generally I&#8217;d say you really missed the whole point of Mark&#8217;s post.  It&#8217;s not about making the computer do the right thing.  That&#8217;s easy.  The hard part is helping humans understand what is happening.  Nested ternary statements fail the latter.  ALWAYS.  </p>
<p>In fact, to add to Mark&#8217;s general rule of thumb &#8211; I will just go ahead and say never nest statements more than one level deep.  You&#8217;ve done something wrong if you need that level of complexity.  Break it down.  Simplify it &#8211; and write for the junior level coder that will be maintaining your code after you are long gone sipping margaritas on the beach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre</title>
		<link>http://blog.markturansky.com/archives/70/comment-page-1#comment-684</link>
		<dc:creator>Dimitre</dc:creator>
		<pubDate>Thu, 10 Apr 2008 19:41:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/70#comment-684</guid>
		<description>String successStr = step1Succeeded ? “success” :
step2Succeeded ? “success” :
“fail”;

breaks the other rule: &quot;Don&#039;t make me think&quot;.... i.e. if you think what it means you&#039;ll get it, but you won&#039;t get it without thinking.</description>
		<content:encoded><![CDATA[<p>String successStr = step1Succeeded ? “success” :<br />
step2Succeeded ? “success” :<br />
“fail”;</p>
<p>breaks the other rule: &#8220;Don&#8217;t make me think&#8221;&#8230;. i.e. if you think what it means you&#8217;ll get it, but you won&#8217;t get it without thinking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DAR</title>
		<link>http://blog.markturansky.com/archives/70/comment-page-1#comment-606</link>
		<dc:creator>DAR</dc:creator>
		<pubDate>Fri, 28 Mar 2008 14:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/70#comment-606</guid>
		<description>Great.  My formatting got stripped.

Look here if you want to see the formatting I&#039;m talking about:

http://darose.net/NestedTernaryFormatting.html</description>
		<content:encoded><![CDATA[<p>Great.  My formatting got stripped.</p>
<p>Look here if you want to see the formatting I&#8217;m talking about:</p>
<p><a href="http://darose.net/NestedTernaryFormatting.html" rel="nofollow">http://darose.net/NestedTernaryFormatting.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DAR</title>
		<link>http://blog.markturansky.com/archives/70/comment-page-1#comment-605</link>
		<dc:creator>DAR</dc:creator>
		<pubDate>Fri, 28 Mar 2008 14:39:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/70#comment-605</guid>
		<description>&lt;i&gt;Never nest ternary statements&lt;/i&gt;

Disagree.  Ternary statements get a bad rap, and IMO the reason is because people don&#039;t format them properly.  When you write them like this, they&#039; actually quite readable.


String successStr =
	step1Succeeded
		? &quot;success&quot;
		: step2Succeeded
			? &quot;success&quot;
			: &quot;fail&quot;;


or


String successStr =	step1Succeeded ?	&quot;success&quot; :
			step2Succeeded ?	&quot;success&quot; :
						&quot;fail&quot;;
</description>
		<content:encoded><![CDATA[<p><i>Never nest ternary statements</i></p>
<p>Disagree.  Ternary statements get a bad rap, and IMO the reason is because people don&#8217;t format them properly.  When you write them like this, they&#8217; actually quite readable.</p>
<p>String successStr =<br />
	step1Succeeded<br />
		? &#8220;success&#8221;<br />
		: step2Succeeded<br />
			? &#8220;success&#8221;<br />
			: &#8220;fail&#8221;;</p>
<p>or</p>
<p>String successStr =	step1Succeeded ?	&#8220;success&#8221; :<br />
			step2Succeeded ?	&#8220;success&#8221; :<br />
						&#8220;fail&#8221;;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

