<?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"
	>
<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>
	<pubDate>Sun, 23 Nov 2008 13:20:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<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-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'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'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-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'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-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-&#62;_SomeProperty;
  }
  
  private function setSomeProperty($value)
  {
    //custom code...
    $this-&#62;_SomeProperty = $value;
  }

  public function __get($name)
  {
    $methodName = "get$name";

    if (method_exists($this, $methodName))
      return $this-&#62;$methodName();

    //do catch all stuff here
  }
  
  public function __set($name, $value)
  {
    $methodName = "set$name";
    
    if (method_exists($this, $methodName))
      return $this-&#62;$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-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-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-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 "-&#62;" do in the statement?
(Just realised I hadn'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-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've only worked on php at a low-level (made a website, altered some php code for another), so I'm a bit of a Newbie when it comes to php..

I hope you don'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-&#62;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-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-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. "an function only  do one thing and do it well."</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-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'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'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>
