<?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: __get(): An Alternative to __autoload()</title>
	<atom:link href="http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/</link>
	<description></description>
	<lastBuildDate>Mon, 08 Mar 2010 17:59:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: elias</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-280</link>
		<dc:creator>elias</dc:creator>
		<pubDate>Mon, 09 Jan 2006 14:11:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-280</guid>
		<description>ah now i got your point. besides that my container idea is worth nothing because __get is always public. there no benefits in encapsulation. :)

if you can live with write access to properties, this is a very nice/lazy factory.</description>
		<content:encoded><![CDATA[<p>ah now i got your point. besides that my container idea is worth nothing because __get is always public. there no benefits in encapsulation. :)</p>
<p>if you can live with write access to properties, this is a very nice/lazy factory.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Naberezny</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-279</link>
		<dc:creator>Mike Naberezny</dc:creator>
		<pubDate>Mon, 09 Jan 2006 12:50:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-279</guid>
		<description>It&#039;s only an example and is provided in a simplified form to demonstrate the concept more clearly.  You can implement it in all kinds of fancy permutations.

The point is that an instance variable isn&#039;t set, __get() catches the first access to it, some lazy-load occurs, and then the instance variable is set for future accesses.</description>
		<content:encoded><![CDATA[<p>It&#8217;s only an example and is provided in a simplified form to demonstrate the concept more clearly.  You can implement it in all kinds of fancy permutations.</p>
<p>The point is that an instance variable isn&#8217;t set, __get() catches the first access to it, some lazy-load occurs, and then the instance variable is set for future accesses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lukas</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-278</link>
		<dc:creator>Lukas</dc:creator>
		<pubDate>Mon, 09 Jan 2006 12:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-278</guid>
		<description>Mike I think Stefano is talking about:
return $this-&gt;obj = $obj;</description>
		<content:encoded><![CDATA[<p>Mike I think Stefano is talking about:<br />
return $this-&gt;obj = $obj;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Naberezny</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-277</link>
		<dc:creator>Mike Naberezny</dc:creator>
		<pubDate>Sun, 08 Jan 2006 23:13:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-277</guid>
		<description>Stefano: I&#039;m lost on how you say the example &quot;only manages one instance for every class&quot;.  While the example is just to demonstrate the idea, even the __get() function in the example is written around a switch() construct.  It can handle as many properties as you&#039;d like; &quot;obj&quot; was just one example for demonstration.  You can continue to add them to the switch or use __get() to call whatever fancy object factory you&#039;d like.  The idea isn&#039;t to make __get() a general purpose factory for all your needs, it&#039;s just to facilitate some lazy-load behavior on the class level.  

Elias: You need to read the example again.  The access to &quot;obj&quot; goes to __get() only once.  When that happens, $instance-&gt;obj is then set and __get() never gets hit again, so there&#039;s no overhead.  This is how the idea is somewhat analogous to __autoload().

Mike</description>
		<content:encoded><![CDATA[<p>Stefano: I&#8217;m lost on how you say the example &#8220;only manages one instance for every class&#8221;.  While the example is just to demonstrate the idea, even the __get() function in the example is written around a switch() construct.  It can handle as many properties as you&#8217;d like; &#8220;obj&#8221; was just one example for demonstration.  You can continue to add them to the switch or use __get() to call whatever fancy object factory you&#8217;d like.  The idea isn&#8217;t to make __get() a general purpose factory for all your needs, it&#8217;s just to facilitate some lazy-load behavior on the class level.  </p>
<p>Elias: You need to read the example again.  The access to &#8220;obj&#8221; goes to __get() only once.  When that happens, $instance-&gt;obj is then set and __get() never gets hit again, so there&#8217;s no overhead.  This is how the idea is somewhat analogous to __autoload().</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: elias</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-276</link>
		<dc:creator>elias</dc:creator>
		<pubDate>Sun, 08 Jan 2006 16:28:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-276</guid>
		<description>if you access the property with __get always (and i think that was your intention) you don&#039;t have to access the container directly.</description>
		<content:encoded><![CDATA[<p>if you access the property with __get always (and i think that was your intention) you don&#8217;t have to access the container directly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TAC One</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-275</link>
		<dc:creator>TAC One</dc:creator>
		<pubDate>Sun, 08 Jan 2006 14:28:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-275</guid>
		<description>I don&#039;t see the point for using __get().
Your example also manages only one instance for every class

//not tested
class FrameworkClassFactory {

   function &amp;load ($className) {
        include (ROOT.&#039;/libs/&#039;.$className.&#039;.php&#039;);
        $instance = new $className ();
        return $instance;
   }
}

This sadly doesn&#039;t deal with parameters, you have to use eval () or some kind of acceptable trick (let&#039;s say we surely know we won&#039;t ever need more than 10 parameters).
(warning it won&#039;t handle references parameters)

class FrameworkClassFactory {

   function &amp;load () {
        include (ROOT.&#039;/libs/&#039;.$className.&#039;.php&#039;);
        $p=func_get_args();
        $className=array_shift($p);

        for ($i=0; $i</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see the point for using __get().<br />
Your example also manages only one instance for every class</p>
<p>//not tested<br />
class FrameworkClassFactory {</p>
<p>   function &amp;load ($className) {<br />
        include (ROOT.&#8217;/libs/&#8217;.$className.&#8217;.php&#8217;);<br />
        $instance = new $className ();<br />
        return $instance;<br />
   }<br />
}</p>
<p>This sadly doesn&#8217;t deal with parameters, you have to use eval () or some kind of acceptable trick (let&#8217;s say we surely know we won&#8217;t ever need more than 10 parameters).<br />
(warning it won&#8217;t handle references parameters)</p>
<p>class FrameworkClassFactory {</p>
<p>   function &amp;load () {<br />
        include (ROOT.&#8217;/libs/&#8217;.$className.&#8217;.php&#8217;);<br />
        $p=func_get_args();<br />
        $className=array_shift($p);</p>
<p>        for ($i=0; $i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Naberezny</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-273</link>
		<dc:creator>Mike Naberezny</dc:creator>
		<pubDate>Sun, 08 Jan 2006 13:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-273</guid>
		<description>I corrected the typo, thanks.

Regarding the container, that&#039;s true but then the usage becomes much uglier.  __get() then moves into the container, and the usage becomes $instance-&gt;container-&gt;obj-&gt;test().  That&#039;s not very convenient. </description>
		<content:encoded><![CDATA[<p>I corrected the typo, thanks.</p>
<p>Regarding the container, that&#8217;s true but then the usage becomes much uglier.  __get() then moves into the container, and the usage becomes $instance->container->obj->test().  That&#8217;s not very convenient.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: elias</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-272</link>
		<dc:creator>elias</dc:creator>
		<pubDate>Sun, 08 Jan 2006 13:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-272</guid>
		<description>You can avoid the public visibility, when you put the instances in a private array/object.
Btw. Test::$obj is not accessible, only $testInstance-&gt;obj. You cannot use __get/__set with static access.</description>
		<content:encoded><![CDATA[<p>You can avoid the public visibility, when you put the instances in a private array/object.<br />
Btw. Test::$obj is not accessible, only $testInstance-&gt;obj. You cannot use __get/__set with static access.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johannes</title>
		<link>http://mikenaberezny.com/2006/01/08/__get-an-alternative-to-__autoload/comment-page-1/#comment-271</link>
		<dc:creator>Johannes</dc:creator>
		<pubDate>Sun, 08 Jan 2006 13:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikenaberezny.com/archives/38#comment-271</guid>
		<description>You can also take a look at spl_autoload() which fixes most of the __autload() problems.</description>
		<content:encoded><![CDATA[<p>You can also take a look at spl_autoload() which fixes most of the __autload() problems.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
