<?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>soledad penadés &#187; side effects</title>
	<atom:link href="http://soledadpenades.com/tag/side-effects/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Wed, 25 Apr 2012 21:10:33 +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>WordPress mistery solved!</title>
		<link>http://soledadpenades.com/2009/05/09/wordpress-mistery-solved/</link>
		<comments>http://soledadpenades.com/2009/05/09/wordpress-mistery-solved/#comments</comments>
		<pubDate>Sat, 09 May 2009 11:17:16 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[coding standards]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[side effects]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=980</guid>
		<description><![CDATA[Whenever I looked at source code from WordPress there was something that always irked me, and it was their recurrent use of this style of comparisons: if&#40;2 == $x&#41; I have been using the totally opposite style from the very first time I typed a comparison into a computer&#8230; and that was eons ago, so [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I looked at source code from WordPress there was something that always irked me, and it was their recurrent use of this style of comparisons:</p>
<div class="syhi_block"><code><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span></code></div>
<p>I have been using the totally opposite style from the very first time I typed a comparison into a computer&#8230; and that was <em>eons</em> ago, so I can safely assume and proclaim that I have assimilated it as an instinctive act. I mean, when I think of <em>comparison</em>, this is what I think of:</p>
<div class="syhi_block"><code><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span></code></div>
<p>And so I couldn&#8217;t understand WP&#8217;s style. It didn&#8217;t make sense&#8230; until I found this little paragraph semi-hidden at the very end of their <a href="http://codex.wordpress.org/WordPress_Coding_Standards">Coding Standards</a> document:</p>
<blockquote><p>Another important point in the above example, when doing logical comparisons always put the variable on the right side, like above. If you forget an equal sign it&#8217;ll throw a parse error instead of just evaluating true and executing the statement. It really takes no extra time to do, so if this saves one bug it&#8217;s worth it. </p></blockquote>
<p>So that was it!</p>
<p>But although that now makes sense &#8212; I have lost count of the amount of times I have been asked <q>why does my code not work? it looks fine</q> just to quickly find the reason was they were using an assignment instead of a comparison, I am not going to follow that guideline. It just doesn&#8217;t feel right, it looks awkward to me, unnatural and <em>overengineered</em>. Besides, I never make those mistakes, of course ;)</p>
<p>Coincidentally, I was testing Netbeans with PHP yesterday. It has a feature which warns you if your comparisons have unintentional side effects, which is the very same problem WP developers are trying to prevent with that coding rule. Maybe the solution is not to change the code style but to use tools like Netbeans.</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=980&amp;md5=63c190853bd24cb872fe74cefc7c7824" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2009/05/09/wordpress-mistery-solved/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=8399&amp;amp;url=http%3A%2F%2Fsoledadpenades.com%2F2009%2F05%2F09%2Fwordpress-mistery-solved%2F&amp;amp;language=en_GB&amp;amp;category=text&amp;amp;title=WordPress+mistery+solved%21&amp;amp;description=Whenever+I+looked+at+source+code+from+WordPress+there+was+something+that+always+irked+me%2C+and+it+was+their+recurrent+use+of+this+style+of+comparisons%3A%0D%0A%0D%0A%0D%0Aif%282+%3D%3D+%24x%29%0D%0A%0D%0A%0D%0AI+have+been+using+the+totally+opposite+style+from+the+very+first+time+I+typed+a+comparison+into+a+computer...+and+that+was+eons+ago%2C+so+I+can+safely+assume+and+proclaim+that+I+have+assimilated+it+as+an+instinctive+act.+I+mean%2C+when+I+think+of+comparison%2C+this+is+what+I+think+of%3A%0D%0A%0D%0A%0D%0Aif%28%24x+%3D%3D+2%29%0D%0A%0D%0A%0D%0AAnd+so+I+couldn%27t+understand+WP%27s+style.+It+didn%27t+make+sense...+until+I+found+this+little+paragraph+semi-hidden+at+the+very+end+of+their+Coding+Standards+document%3A%0D%0A%0D%0AAnother+important+point+in+the+above+example%2C+when+doing+logical+comparisons+always+put+the+variable+on+the+right+side%2C+like+above.+If+you+forget+an+equal+sign+it%27ll+throw+a+parse+error+instead+of+just+evaluating+true+and+executing+the+statement.+It+really+takes+no+extra+time+to+do%2C+so+if+this+saves+one+bug+it%27s+worth+it.+%0D%0A%0D%0ASo+that+was+it%21%0D%0A%0D%0ABut+although+that+now+makes+sense+--+I+have+lost+count+of+the+amount+of+times+I+have+been+asked+why+does+my+code+not+work%3F+it+looks+fine+just+to+quickly+find+the+reason+was+they+were+using+an+assignment+instead+of+a+comparison%2C+I+am+not+going+to+follow+that+guideline.+It+just+doesn%27t+feel+right%2C+it+looks+awkward+to+me%2C+unnatural+and+overengineered.+Besides%2C+I+never+make+those+mistakes%2C+of+course+%3B%29%0D%0A%0D%0ACoincidentally%2C+I+was+testing+Netbeans+with+PHP+yesterday.+It+has+a+feature+which+warns+you+if+your+comparisons+have+unintentional+side+effects%2C+which+is+the+very+same+problem+WP+developers+are+trying+to+prevent+with+that+coding+rule.+Maybe+the+solution+is+not+to+change+the+code+style+but+to+use+tools+like+Netbeans.&amp;amp;tags=coding+standards%2Cnetbeans%2Cphp%2Cside+effects%2Cwordpress%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>

