<?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: A Note on Google&#8217;s So-called Best Practices</title>
	<atom:link href="http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Sun, 22 Nov 2009 11:54:05 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dorsey</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-928017</link>
		<dc:creator>Dorsey</dc:creator>
		<pubDate>Thu, 02 Jul 2009 22:58:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-928017</guid>
		<description>Google should focus on their core competency, which is wringing maximum revenue from search and search-related products and services.  For them to advise the world on how to improve our source code is well beyond their charter and comfort zone.

That said, what they&#039;ve written falls into two categories:  making code easier to read, and Algorithm Design 101.  Any company that performs routine code reviews will come up with many more &quot;improvements&quot; than are on Google&#039;s list.  Google did make one valid point that many still haven&#039;t learned, and that is rather than guessing at where the &quot;hot spots&quot; are, use a profiling tool that will actually tell you.</description>
		<content:encoded><![CDATA[<p>Google should focus on their core competency, which is wringing maximum revenue from search and search-related products and services.  For them to advise the world on how to improve our source code is well beyond their charter and comfort zone.</p>
<p>That said, what they&#8217;ve written falls into two categories:  making code easier to read, and Algorithm Design 101.  Any company that performs routine code reviews will come up with many more &#8220;improvements&#8221; than are on Google&#8217;s list.  Google did make one valid point that many still haven&#8217;t learned, and that is rather than guessing at where the &#8220;hot spots&#8221; are, use a profiling tool that will actually tell you.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: omnicity</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927877</link>
		<dc:creator>omnicity</dc:creator>
		<pubDate>Tue, 30 Jun 2009 21:24:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927877</guid>
		<description>The two most important lessons I have learned about performance are:
1) It all depends on the exact circumstances
2) Even if something looks logically simpler, always do a real-world test before changing simply for speed.

Unfortunatly, I see more awareness of these two rules in the Google article than in the comments here, so my thanks go out to him for having the courage to start an important debate.</description>
		<content:encoded><![CDATA[<p>The two most important lessons I have learned about performance are:<br />
1) It all depends on the exact circumstances<br />
2) Even if something looks logically simpler, always do a real-world test before changing simply for speed.</p>
<p>Unfortunatly, I see more awareness of these two rules in the Google article than in the comments here, so my thanks go out to him for having the courage to start an important debate.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927761</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 29 Jun 2009 14:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927761</guid>
		<description>@wardrop:
&lt;blockquote&gt;You bash an authors article, and you’re effectively bashing the author.&lt;/blockquote&gt;
Um, no, this is the exact opposite of an &lt;a href=&quot;http://en.wikipedia.org/wiki/Ad_hominem&quot; rel=&quot;nofollow&quot;&gt;ad-hominem&lt;/a&gt;. We are supposed to be good at logic. And, according to the author of this post, the individual points mentioned in the post are wrong (he might be wrong about that, sure). How should he call them? If the points the original post argues for are not true anymore under PHP 5, and the author doesn&#039;t point that out, the post is wrong. Not &#039;almost right&#039;, wrong.
&lt;blockquote&gt;Sure, assigning a variable would speed up the if/else syntax, but it’s unnecessary when the switch/case syntax can achieve the same thing without populating the namespace you’re in&lt;/blockquote&gt;
I think it just meant that your example is contrived. I think that the switch-case statement is more readable than a string of elseifs, and that the namespace pollution is the real issue, but your example isn&#039;t fair. You could have also used a more concise syntax with the opening and closing brackets in the same line as the expressions or the elses:
&lt;code&gt;$calc = calculate($var1);
if ($calc == ‘horse’) {
// Do this
} else if ($calc == ‘donkey’) {
// Do this
}&lt;/code&gt;
A bit more similar to the switch, isn&#039;t it? &lt;em&gt;Now&lt;/em&gt; you could argue that the namespace is a little less polluted, and that the switch is more readable without the syntax or the function getting in the way of your point.</description>
		<content:encoded><![CDATA[<p>@wardrop:</p>
<blockquote><p>You bash an authors article, and you’re effectively bashing the author.</p></blockquote>
<p>Um, no, this is the exact opposite of an <a href="http://en.wikipedia.org/wiki/Ad_hominem" rel="nofollow">ad-hominem</a>. We are supposed to be good at logic. And, according to the author of this post, the individual points mentioned in the post are wrong (he might be wrong about that, sure). How should he call them? If the points the original post argues for are not true anymore under PHP 5, and the author doesn&#8217;t point that out, the post is wrong. Not &#8216;almost right&#8217;, wrong.</p>
<blockquote><p>Sure, assigning a variable would speed up the if/else syntax, but it’s unnecessary when the switch/case syntax can achieve the same thing without populating the namespace you’re in</p></blockquote>
<p>I think it just meant that your example is contrived. I think that the switch-case statement is more readable than a string of elseifs, and that the namespace pollution is the real issue, but your example isn&#8217;t fair. You could have also used a more concise syntax with the opening and closing brackets in the same line as the expressions or the elses:<br />
<code>$calc = calculate($var1);
if ($calc == ‘horse’) {
// Do this
} else if ($calc == ‘donkey’) {
// Do this
}</code><br />
A bit more similar to the switch, isn&#8217;t it? <em>Now</em> you could argue that the namespace is a little less polluted, and that the switch is more readable without the syntax or the function getting in the way of your point.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: PatrickSamphire</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927747</link>
		<dc:creator>PatrickSamphire</dc:creator>
		<pubDate>Mon, 29 Jun 2009 10:28:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927747</guid>
		<description>&lt;blockquote&gt;Ph.D’s are the most ignorant smart people you will find. Most have not had a real job. Most have the creativity of a turnip.&lt;/blockquote&gt;
This may be the most absurd comment in the thread so far. If someone is working for google, they &lt;strong&gt;have&lt;/strong&gt; a real job. Anyone working for a salary has a real job. This stupid snobbishness doesn&#039;t help the debate at all.</description>
		<content:encoded><![CDATA[<blockquote><p>Ph.D’s are the most ignorant smart people you will find. Most have not had a real job. Most have the creativity of a turnip.</p></blockquote>
<p>This may be the most absurd comment in the thread so far. If someone is working for google, they <strong>have</strong> a real job. Anyone working for a salary has a real job. This stupid snobbishness doesn&#8217;t help the debate at all.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Arkh</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927746</link>
		<dc:creator>Arkh</dc:creator>
		<pubDate>Mon, 29 Jun 2009 10:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927746</guid>
		<description>Let&#039;s be honest. PhP is not C : if you want perfs you don&#039;t choose it. Wasting hours to gain 1ms of execution time, getting a less readable code while your Db connexion are using dozens ms ? Not worth it.
Start by getting a working and as secure as you can app. Optimize your server config. Optimize your db requests. Then you can think about getting some ms from your php code if you still have time for that.</description>
		<content:encoded><![CDATA[<p>Let&#8217;s be honest. PhP is not C : if you want perfs you don&#8217;t choose it. Wasting hours to gain 1ms of execution time, getting a less readable code while your Db connexion are using dozens ms ? Not worth it.<br />
Start by getting a working and as secure as you can app. Optimize your server config. Optimize your db requests. Then you can think about getting some ms from your php code if you still have time for that.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: -T-</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927721</link>
		<dc:creator>-T-</dc:creator>
		<pubDate>Sun, 28 Jun 2009 15:16:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927721</guid>
		<description>I usually just follow the tips posted at http://www.phpbench.com/
They seem to be solid enough

&lt;code&gt;
$precalculatedCount = sizeof($array);
for($i=0; $i &lt; $precalculatedCount; $i++)
{...}

// instead of

for($i=0;$i &lt; sizeof($array);$i++)
{...}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I usually just follow the tips posted at <a href="http://www.phpbench.com/" rel="nofollow">http://www.phpbench.com/</a><br />
They seem to be solid enough</p>
<code>
$precalculatedCount = sizeof($array);
for($i=0; $i &lt; $precalculatedCount; $i++)
{...}

// instead of

for($i=0;$i &lt; sizeof($array);$i++)
{...}
</code>]]></content:encoded>
	</item>
	<item>
		<title>By: Hamranhansenhansen</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927660</link>
		<dc:creator>Hamranhansenhansen</dc:creator>
		<pubDate>Sat, 27 Jun 2009 00:57:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927660</guid>
		<description>Writing for Google doesn&#039;t mean a single thing. You can&#039;t trust Google any more than anyone else. Perhaps less, because Google has a fairly unique position on the Web and things that work for them may be opposite to you. Also, Google is about 98% Ph.D&#039;s, which on one hand is great, but on the other hand, Ph.D&#039;s are the most ignorant smart people you will find. Most have not had a real job. Most have the creativity of a turnip.

It&#039;s better to Google &quot;PHP optimization&quot; than to read an article on PHP optimization by someone who works at Google. If you want to take Google&#039;s advice, stop using Microsoft products. That is PHP&#039;s advice also and mine too.</description>
		<content:encoded><![CDATA[<p>Writing for Google doesn&#8217;t mean a single thing. You can&#8217;t trust Google any more than anyone else. Perhaps less, because Google has a fairly unique position on the Web and things that work for them may be opposite to you. Also, Google is about 98% Ph.D&#8217;s, which on one hand is great, but on the other hand, Ph.D&#8217;s are the most ignorant smart people you will find. Most have not had a real job. Most have the creativity of a turnip.</p>
<p>It&#8217;s better to Google &#8220;PHP optimization&#8221; than to read an article on PHP optimization by someone who works at Google. If you want to take Google&#8217;s advice, stop using Microsoft products. That is PHP&#8217;s advice also and mine too.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wardrop</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927654</link>
		<dc:creator>Wardrop</dc:creator>
		<pubDate>Fri, 26 Jun 2009 23:17:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927654</guid>
		<description>@nrg_alpha...

Sure, assigning a variable would speed up the if/else syntax, but it&#039;s unnecessary when the switch/case syntax can achieve the same thing without populating the namespace you&#039;re in. Plus in such a scenario, the switch/case statement is much cleaner.

@Troels...

You bash an authors article, and you&#039;re effectively bashing the author. I understand that as Google, you probably would expect a little more from them in terms of the quality of their tips (these tips are very short and to the point, they could have been elaborated), along with their explanations and examples, but I don&#039;t agree with summarising the article as &quot;border-line ridiculous&quot; or &quot;wrong&quot;. All he&#039;s suggesting are best practices, which as a bonus, get you a slight performance improvement. He even mentions toward the beginning of the article...

&lt;blockquote&gt;Premature optimization is the root of all evil&lt;/blockquote&gt;

As I&#039;ve said, I can&#039;t fault any of the authors tips. If there&#039;s one thing the authors done wrong, it&#039;s not elaborating on each of his points a little more.</description>
		<content:encoded><![CDATA[<p>@nrg_alpha&#8230;</p>
<p>Sure, assigning a variable would speed up the if/else syntax, but it&#8217;s unnecessary when the switch/case syntax can achieve the same thing without populating the namespace you&#8217;re in. Plus in such a scenario, the switch/case statement is much cleaner.</p>
<p>@Troels&#8230;</p>
<p>You bash an authors article, and you&#8217;re effectively bashing the author. I understand that as Google, you probably would expect a little more from them in terms of the quality of their tips (these tips are very short and to the point, they could have been elaborated), along with their explanations and examples, but I don&#8217;t agree with summarising the article as &#8220;border-line ridiculous&#8221; or &#8220;wrong&#8221;. All he&#8217;s suggesting are best practices, which as a bonus, get you a slight performance improvement. He even mentions toward the beginning of the article&#8230;</p>
<blockquote><p>Premature optimization is the root of all evil</p></blockquote>
<p>As I&#8217;ve said, I can&#8217;t fault any of the authors tips. If there&#8217;s one thing the authors done wrong, it&#8217;s not elaborating on each of his points a little more.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: nrg_alpha</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927648</link>
		<dc:creator>nrg_alpha</dc:creator>
		<pubDate>Fri, 26 Jun 2009 18:42:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927648</guid>
		<description>@Wardrop: Granted, your code example of the if/else statement is not a fair comparison, as you are executing calculate($var1) in every condition, which is not wise coding practice. That would be akin to always executing say count() in a for loop;

for ($a = 0 ; $a &lt; count($var1) ; $a++) {
	// do something;
}

The smarter comparison would be to assign calculate($var1) to a variable [i]once[/i], then throw that through your if/else statement:

$calc = calculate($var1);
if($calc == ‘horse’)
{
// Do this
}
else if($calc == ‘donkey’)
{
// Do this
}
....

Of course, in this hypothetical situation we don&#039;t know what the function calculate() does.. but it doesn&#039;t matter. Having the PHP engine do more work than necessary is just plain bad practice.</description>
		<content:encoded><![CDATA[<p>@Wardrop: Granted, your code example of the if/else statement is not a fair comparison, as you are executing calculate($var1) in every condition, which is not wise coding practice. That would be akin to always executing say count() in a for loop;</p>
<p>for ($a = 0 ; $a &lt; count($var1) ; $a++) {<br />
	// do something;<br />
}</p>
<p>The smarter comparison would be to assign calculate($var1) to a variable [i]once[/i], then throw that through your if/else statement:</p>
<p>$calc = calculate($var1);<br />
if($calc == ‘horse’)<br />
{<br />
// Do this<br />
}<br />
else if($calc == ‘donkey’)<br />
{<br />
// Do this<br />
}<br />
&#8230;.</p>
<p>Of course, in this hypothetical situation we don&#8217;t know what the function calculate() does.. but it doesn&#8217;t matter. Having the PHP engine do more work than necessary is just plain bad practice.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Grossman</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/comment-page-1/#comment-927638</link>
		<dc:creator>Dan Grossman</dc:creator>
		<pubDate>Fri, 26 Jun 2009 17:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556#comment-927638</guid>
		<description>@Jasc: Nobody here is talking about such a language, as that certainly doesn&#039;t describe PHP. Were you referring to Java perhaps?</description>
		<content:encoded><![CDATA[<p>@Jasc: Nobody here is talking about such a language, as that certainly doesn&#8217;t describe PHP. Were you referring to Java perhaps?</p>]]></content:encoded>
	</item>
</channel>
</rss>
