<?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 3: Replace Temp with Query</title>
	<atom:link href="http://www.codediesel.com/refactoring/refactoring-3-replace-temp-with-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/</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: mathk</title>
		<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/comment-page-1/#comment-1344</link>
		<dc:creator>mathk</dc:creator>
		<pubDate>Tue, 18 Aug 2009 07:35:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=963#comment-1344</guid>
		<description>I also see a main avantage: 
If you ever decide to add a new item with a new way of computing the discount you just have to subclass your item and redefine the dicount_factor() method. Nothing more! :)</description>
		<content:encoded><![CDATA[<p>I also see a main avantage:<br />
If you ever decide to add a new item with a new way of computing the discount you just have to subclass your item and redefine the dicount_factor() method. Nothing more! <img src='http://www.codediesel.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Favio</title>
		<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/comment-page-1/#comment-1324</link>
		<dc:creator>Favio</dc:creator>
		<pubDate>Fri, 07 Aug 2009 08:26:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=963#comment-1324</guid>
		<description>What do you think about writing the discount_factor function as:

private function discount_factor() {
    if($this-&gt;base_price() &gt; 1000) {
        return 0.95;
    }
    return 0.98;
}

?

Anyway, you have a cool blog. :)</description>
		<content:encoded><![CDATA[<p>What do you think about writing the discount_factor function as:</p>
<p>private function discount_factor() {<br />
    if($this-&gt;base_price() &gt; 1000) {<br />
        return 0.95;<br />
    }<br />
    return 0.98;<br />
}</p>
<p>?</p>
<p>Anyway, you have a cool blog. <img src='http://www.codediesel.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Refactoring 3: Replace Temp with Query : CodeDiesel</title>
		<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/comment-page-1/#comment-1271</link>
		<dc:creator>Refactoring 3: Replace Temp with Query : CodeDiesel</dc:creator>
		<pubDate>Sat, 04 Jul 2009 07:34:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=963#comment-1271</guid>
		<description>[...] the original post here: Refactoring 3: Replace Temp with Query : CodeDiesel   Share and [...]</description>
		<content:encoded><![CDATA[<p>[...] the original post here: Refactoring 3: Replace Temp with Query : CodeDiesel   Share and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/comment-page-1/#comment-1245</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 10 Jun 2009 12:34:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=963#comment-1245</guid>
		<description>Thanks for this, great refactoring articles!</description>
		<content:encoded><![CDATA[<p>Thanks for this, great refactoring articles!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raphaël Dehousse</title>
		<link>http://www.codediesel.com/software/refactoring-3-replace-temp-with-query/comment-page-1/#comment-1240</link>
		<dc:creator>Raphaël Dehousse</dc:creator>
		<pubDate>Mon, 08 Jun 2009 13:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=963#comment-1240</guid>
		<description>Hello,

Ok for the pattern but in your example, I would rather write :

     private function discount_factor($base_price) {
          if($base_price &gt; 1000)
               return 0.95;
          else
               return 0.98;
     }
 
     public function get_price() {
          $base_price = $this-&gt;base_price();
 
          return ($base_price * $this-&gt;discount_factor($base_price));
     }

You will save one function call and like this, you can use discount_factor on other price than the base one of your class

Thanks for your articles !

Cheers,

Raphaël</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Ok for the pattern but in your example, I would rather write :</p>
<p>     private function discount_factor($base_price) {<br />
          if($base_price > 1000)<br />
               return 0.95;<br />
          else<br />
               return 0.98;<br />
     }</p>
<p>     public function get_price() {<br />
          $base_price = $this->base_price();</p>
<p>          return ($base_price * $this->discount_factor($base_price));<br />
     }</p>
<p>You will save one function call and like this, you can use discount_factor on other price than the base one of your class</p>
<p>Thanks for your articles !</p>
<p>Cheers,</p>
<p>Raphaël</p>
]]></content:encoded>
	</item>
</channel>
</rss>

