<?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: Refactoring 1: Consolidating Conditional Expressions</title>
	<atom:link href="http://www.codediesel.com/php/refactoring-1-consolidate-conditional-expression/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/</link>
	<description>/* PHP &#38; MySQL Journal */</description>
	<lastBuildDate>Fri, 27 Jan 2012 16:39:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: sameer</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1060</link>
		<dc:creator>sameer</dc:creator>
		<pubDate>Thu, 08 Jan 2009 17:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1060</guid>
		<description>Always write tests first and then refactor.</description>
		<content:encoded><![CDATA[<p>Always write tests first and then refactor.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Gutierrez</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1059</link>
		<dc:creator>Joseph Gutierrez</dc:creator>
		<pubDate>Thu, 08 Jan 2009 15:56:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1059</guid>
		<description>&quot;...The important part is to test your code after refactoring.&quot;

In this quote from your initial post do you write tests first, then refactor? Or do you write code then tests?</description>
		<content:encoded><![CDATA[<p>&#8220;&#8230;The important part is to test your code after refactoring.&#8221;</p>
<p>In this quote from your initial post do you write tests first, then refactor? Or do you write code then tests?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sameer</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1058</link>
		<dc:creator>sameer</dc:creator>
		<pubDate>Thu, 08 Jan 2009 04:15:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1058</guid>
		<description>I understand the importance of unit tests as mentioned in my earlier post &#039;Refactoring: An introduction for PHP programmers&#039; but have left it out on purpose.</description>
		<content:encoded><![CDATA[<p>I understand the importance of unit tests as mentioned in my earlier post &#8216;Refactoring: An introduction for PHP programmers&#8217; but have left it out on purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Gutierrez</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1057</link>
		<dc:creator>Joseph Gutierrez</dc:creator>
		<pubDate>Wed, 07 Jan 2009 19:16:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1057</guid>
		<description>Where are your unit tests? Any refactorings require unit tests. If you want to make sure you don&#039;t change the behavior (logic) of your conditionals you need some unit tests.</description>
		<content:encoded><![CDATA[<p>Where are your unit tests? Any refactorings require unit tests. If you want to make sure you don&#8217;t change the behavior (logic) of your conditionals you need some unit tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lloyd27</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1055</link>
		<dc:creator>lloyd27</dc:creator>
		<pubDate>Tue, 06 Jan 2009 17:23:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1055</guid>
		<description>There are a few things i don&#039;t like of this code..
The lacks of braces, the fact you&#039;re returning 1 and 0 instead of true and false (which would be more semantically correct), the mixed usage of tabs and spaces to indent (spaces for life :D)..
Even the name of the method &quot;check_security_status&quot; is not fully semantically correct: isAdmin, or isSecure or something like that would be fine instead. A method that returns a boolean (or 1 and 0 in your case) IMHO should be called is... or can... or has...
I would refactor like this
&lt;code&gt;
  public function can_upload_file()
  {
    return $this-&gt;_isAdmin and $this-&gt;isHttps and ($this-&gt;totalLoginsPerDay &lt;= 100);
  }
&lt;/code&gt;
This is more meaningful, easier to read and even shorter.. If you want you can separate in two different methods, but unless the new one is called somewhere else in the code, it would be pretty useless..</description>
		<content:encoded><![CDATA[<p>There are a few things i don&#8217;t like of this code..<br />
The lacks of braces, the fact you&#8217;re returning 1 and 0 instead of true and false (which would be more semantically correct), the mixed usage of tabs and spaces to indent (spaces for life <img src='http://www.codediesel.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )..<br />
Even the name of the method &#8220;check_security_status&#8221; is not fully semantically correct: isAdmin, or isSecure or something like that would be fine instead. A method that returns a boolean (or 1 and 0 in your case) IMHO should be called is&#8230; or can&#8230; or has&#8230;<br />
I would refactor like this<br />
<code><br />
  public function can_upload_file()<br />
  {<br />
    return $this-&gt;_isAdmin and $this-&gt;isHttps and ($this-&gt;totalLoginsPerDay &lt;= 100);<br />
  }<br />
</code><br />
This is more meaningful, easier to read and even shorter.. If you want you can separate in two different methods, but unless the new one is called somewhere else in the code, it would be pretty useless..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1054</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Tue, 06 Jan 2009 12:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1054</guid>
		<description>I know it&#039;s only a short example but for the uneducated short examples are mostly meaningless.

For greater benefit, wouldn&#039;t it be better to demonstrate with a real world example - actual application script with proper unit tests?

People would learn more and quickly if they saw how the refactor effects the wider application layer, but my concern can be noted not just for this blog but a 1000 others too.

It&#039;s unfortunate.</description>
		<content:encoded><![CDATA[<p>I know it&#8217;s only a short example but for the uneducated short examples are mostly meaningless.</p>
<p>For greater benefit, wouldn&#8217;t it be better to demonstrate with a real world example &#8211; actual application script with proper unit tests?</p>
<p>People would learn more and quickly if they saw how the refactor effects the wider application layer, but my concern can be noted not just for this blog but a 1000 others too.</p>
<p>It&#8217;s unfortunate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bugz</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1053</link>
		<dc:creator>Bugz</dc:creator>
		<pubDate>Tue, 06 Jan 2009 11:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1053</guid>
		<description>I have noticed that most people want to use refactoring to reduce the number of lines in their code, and even though most times there will be a code-volume reduction, the main objective of refactoring is to make the code more efficient, easier to handle and reusable.
When you refactor a project, you must aim at making the code the most reusable and simple as possible. Some times that will generate more lines of code than the original code, but it should be simpler to maintain.
Finally, one point that I think is very important to keep in mind is the fact that refactoring should be handled with the greatest care possible, documenting your project should in general, be the first step before refactoring anything to avoid refactoring you refactoring.</description>
		<content:encoded><![CDATA[<p>I have noticed that most people want to use refactoring to reduce the number of lines in their code, and even though most times there will be a code-volume reduction, the main objective of refactoring is to make the code more efficient, easier to handle and reusable.<br />
When you refactor a project, you must aim at making the code the most reusable and simple as possible. Some times that will generate more lines of code than the original code, but it should be simpler to maintain.<br />
Finally, one point that I think is very important to keep in mind is the fact that refactoring should be handled with the greatest care possible, documenting your project should in general, be the first step before refactoring anything to avoid refactoring you refactoring.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sameer Borate&#8217;s Blog: Refactoring 1: Consolidating Conditional Expressions : Dragonfly Networks</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1052</link>
		<dc:creator>Sameer Borate&#8217;s Blog: Refactoring 1: Consolidating Conditional Expressions : Dragonfly Networks</dc:creator>
		<pubDate>Tue, 06 Jan 2009 10:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1052</guid>
		<description>[...] has posted the first article in his &#8220;Refactoring&#8221; series today - a look at boiling down conditional expressions to [...]</description>
		<content:encoded><![CDATA[<p>[...] has posted the first article in his &#8220;Refactoring&#8221; series today &#8211; a look at boiling down conditional expressions to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Weier O'Phinney</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1049</link>
		<dc:creator>Matthew Weier O'Phinney</dc:creator>
		<pubDate>Mon, 05 Jan 2009 16:49:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1049</guid>
		<description>Please, please, please don&#039;t show if/then/else statements that do not use braces. Omitting braces is an easy way to slip into debugging hell later when you need to add additional statements, and is the reason why most public coding standards insist on braces for all conditionals.</description>
		<content:encoded><![CDATA[<p>Please, please, please don&#8217;t show if/then/else statements that do not use braces. Omitting braces is an easy way to slip into debugging hell later when you need to add additional statements, and is the reason why most public coding standards insist on braces for all conditionals.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wally</title>
		<link>http://www.codediesel.com/software/refactoring-1-consolidate-conditional-expression/comment-page-1/#comment-1048</link>
		<dc:creator>Wally</dc:creator>
		<pubDate>Sun, 04 Jan 2009 18:58:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=154#comment-1048</guid>
		<description>this works and a bit shorter.
&lt;code&gt;
private function check_security_status() {
  return ($this-&gt;_isHttps === false &#124;&#124; 
	      $this-&gt;_isAdmin === false &#124;&#124; 
	      $this-&gt;_totalLoginsPerDay &gt; 100);
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>this works and a bit shorter.<br />
<code><br />
private function check_security_status() {<br />
  return ($this-&gt;_isHttps === false ||<br />
	      $this-&gt;_isAdmin === false ||<br />
	      $this-&gt;_totalLoginsPerDay &gt; 100);<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

