<?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: Quick Tip: Get, Set and Query in One Method</title>
	<atom:link href="http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/</link>
	<description>Stuart Herbert's PHP Blog - Architecture, Code, and Hosting</description>
	<lastBuildDate>Fri, 20 Aug 2010 11:10:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: M L</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-15215</link>
		<dc:creator>M L</dc:creator>
		<pubDate>Fri, 22 Feb 2008 16:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-15215</guid>
		<description>It benchmarked at about 3 times longer than your method.  Not a nice trade-off for readability.  But traditional getX and setX methods were faster than your single method and don&#039;t have the non-null requirement for the property.

Could you clarify the difference between query and get?  It seems to me that your code acts like a getCanCache method when you don&#039;t pass any parameters (or pass null) and acts like a setCanCache when you do.</description>
		<content:encoded><![CDATA[<p>It benchmarked at about 3 times longer than your method.  Not a nice trade-off for readability.  But traditional getX and setX methods were faster than your single method and don&#8217;t have the non-null requirement for the property.</p>
<p>Could you clarify the difference between query and get?  It seems to me that your code acts like a getCanCache method when you don&#8217;t pass any parameters (or pass null) and acts like a setCanCache when you do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stu</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-15177</link>
		<dc:creator>Stu</dc:creator>
		<pubDate>Fri, 22 Feb 2008 07:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-15177</guid>
		<description>@M L: what&#039;s the performance cost of doing it that way?  How do you support the tristate syntax I put forward in my original example?

Best regards,
Stu</description>
		<content:encoded><![CDATA[<p>@M L: what&#8217;s the performance cost of doing it that way?  How do you support the tristate syntax I put forward in my original example?</p>
<p>Best regards,<br />
Stu</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M L</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-15143</link>
		<dc:creator>M L</dc:creator>
		<pubDate>Fri, 22 Feb 2008 00:39:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-15143</guid>
		<description>Here is what I was getting at:

class HidingExample
{
  private $_SomeProperty;

  private function getSomeProperty()
  {
    //custom code...
    return $this-&gt;_SomeProperty;
  }
  
  private function setSomeProperty($value)
  {
    //custom code...
    $this-&gt;_SomeProperty = $value;
  }

  public function __get($name)
  {
    $methodName = &quot;get$name&quot;;

    if (method_exists($this, $methodName))
      return $this-&gt;$methodName();

    //do catch all stuff here
  }
  
  public function __set($name, $value)
  {
    $methodName = &quot;set$name&quot;;
    
    if (method_exists($this, $methodName))
      return $this-&gt;$methodName($value);

    //do catch all stuff here
  }
}</description>
		<content:encoded><![CDATA[<p>Here is what I was getting at:</p>
<p>class HidingExample<br />
{<br />
  private $_SomeProperty;</p>
<p>  private function getSomeProperty()<br />
  {<br />
    //custom code&#8230;<br />
    return $this-&gt;_SomeProperty;<br />
  }</p>
<p>  private function setSomeProperty($value)<br />
  {<br />
    //custom code&#8230;<br />
    $this-&gt;_SomeProperty = $value;<br />
  }</p>
<p>  public function __get($name)<br />
  {<br />
    $methodName = &#8220;get$name&#8221;;</p>
<p>    if (method_exists($this, $methodName))<br />
      return $this-&gt;$methodName();</p>
<p>    //do catch all stuff here<br />
  }</p>
<p>  public function __set($name, $value)<br />
  {<br />
    $methodName = &#8220;set$name&#8221;;</p>
<p>    if (method_exists($this, $methodName))<br />
      return $this-&gt;$methodName($value);</p>
<p>    //do catch all stuff here<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stu</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-15106</link>
		<dc:creator>Stu</dc:creator>
		<pubDate>Thu, 21 Feb 2008 17:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-15106</guid>
		<description>@M L: __get and __set are great as a general catch-all, but they quickly become unmaintainable if you need different behaviour for each of the attributes that you are hiding.</description>
		<content:encoded><![CDATA[<p>@M L: __get and __set are great as a general catch-all, but they quickly become unmaintainable if you need different behaviour for each of the attributes that you are hiding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M L</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-15104</link>
		<dc:creator>M L</dc:creator>
		<pubDate>Thu, 21 Feb 2008 16:04:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-15104</guid>
		<description>The null restriction is enough to discourage this method.

Why not use the member overload methods __get and __set?  With reflection, it could be made even more robust by looking up a private get/set method.</description>
		<content:encoded><![CDATA[<p>The null restriction is enough to discourage this method.</p>
<p>Why not use the member overload methods __get and __set?  With reflection, it could be made even more robust by looking up a private get/set method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirrus</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-10138</link>
		<dc:creator>Kirrus</dc:creator>
		<pubDate>Mon, 17 Dec 2007 16:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-10138</guid>
		<description>As in, what does the &quot;-&gt;&quot; do in the statement?
(Just realised I hadn&#039;t made clear what I was asking :S)</description>
		<content:encoded><![CDATA[<p>As in, what does the &#8220;-&gt;&#8221; do in the statement?<br />
(Just realised I hadn&#8217;t made clear what I was asking :S)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirrus</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-9981</link>
		<dc:creator>Kirrus</dc:creator>
		<pubDate>Fri, 14 Dec 2007 10:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-9981</guid>
		<description>Hello,
I&#039;ve only worked on php at a low-level (made a website, altered some php code for another), so I&#039;m a bit of a Newbie when it comes to php..

I hope you don&#039;t mind me asking, but I see this sort of expression a lot nowadays, and was wondering if you could tell me what it means?

$this-&gt;canCache = false;</description>
		<content:encoded><![CDATA[<p>Hello,<br />
I&#8217;ve only worked on php at a low-level (made a website, altered some php code for another), so I&#8217;m a bit of a Newbie when it comes to php..</p>
<p>I hope you don&#8217;t mind me asking, but I see this sort of expression a lot nowadays, and was wondering if you could tell me what it means?</p>
<p>$this-&gt;canCache = false;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: developercast.com &#187; Stuart Herbert&#8217;s Blog: Quick Tip: Get, Set and Query in One Method</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-9908</link>
		<dc:creator>developercast.com &#187; Stuart Herbert&#8217;s Blog: Quick Tip: Get, Set and Query in One Method</dc:creator>
		<pubDate>Wed, 12 Dec 2007 21:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-9908</guid>
		<description>[...] his blog, Stuart Herbert has a quick tip showing how to mimic a feature of Ruby on Rails:   I&#8217;m still working on the next article in [...]</description>
		<content:encoded><![CDATA[<p>[...] his blog, Stuart Herbert has a quick tip showing how to mimic a feature of Ruby on Rails:   I&#8217;m still working on the next article in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ctx2002</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-9811</link>
		<dc:creator>ctx2002</dc:creator>
		<pubDate>Mon, 10 Dec 2007 21:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-9811</guid>
		<description>this code has many side effect when you passing different value into canCache($newState = null) function.

i have no ruby experience , but why you want to do many things in one method seems violate an  important programming principal. &quot;an function only  do one thing and do it well.&quot;</description>
		<content:encoded><![CDATA[<p>this code has many side effect when you passing different value into canCache($newState = null) function.</p>
<p>i have no ruby experience , but why you want to do many things in one method seems violate an  important programming principal. &#8220;an function only  do one thing and do it well.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre</title>
		<link>http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/comment-page-1/#comment-9797</link>
		<dc:creator>Pierre</dc:creator>
		<pubDate>Mon, 10 Dec 2007 15:26:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stuartherbert.com/php/2007/12/10/quick-tip-get-set-and-query-in-one-method/#comment-9797</guid>
		<description>I prefer KISS, and that&#039;s not simple. People who see calls to canCache() with false, null or true or no arguments several times in one file on several circumstances would be confused if they don&#039;t know what that method does exactly.</description>
		<content:encoded><![CDATA[<p>I prefer KISS, and that&#8217;s not simple. People who see calls to canCache() with false, null or true or no arguments several times in one file on several circumstances would be confused if they don&#8217;t know what that method does exactly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
