<?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: Thinking about the model II</title>
	<atom:link href="http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 16 Mar 2010 00:59:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-124514</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 01 Apr 2009 15:28:20 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-124514</guid>
		<description>@speedmax: Thanks for your comments!

Your concept looks interesting. However, I don&#039;t understand why you use the array syntax to create the hobbies in your example. Wouldn&#039;t it be more logical to use something like:
&lt;code&gt;
echo Person::create(array(
    &#039;name&#039; =&gt; &#039;taylor luk&#039;;
    &#039;hobbies&#039; =&gt; array(
      Hobby::create(array(&#039;title&#039; =&gt; &#039;swimming&#039;)),
      Hobby::create(array(&#039;title&#039; =&gt; &#039;watch tv&#039;))
    )
))
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>@speedmax: Thanks for your comments!</p>
<p>Your concept looks interesting. However, I don&#8217;t understand why you use the array syntax to create the hobbies in your example. Wouldn&#8217;t it be more logical to use something like:<br />
<pre><code>echo Person::create(array(
    'name' =&gt; 'taylor luk';
    'hobbies' =&gt; array(
      Hobby::create(array('title' =&gt; 'swimming')),
      Hobby::create(array('title' =&gt; 'watch tv'))
    )
))</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: speedmax</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-124412</link>
		<dc:creator>speedmax</dc:creator>
		<pubDate>Tue, 31 Mar 2009 03:14:34 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-124412</guid>
		<description>plus the concept code i just posted 
 * can be a lot faster with right engineering and optimizations
 * all association are lazily loaded until its really called (without the mess we have lazy load all models, Containable + findAll)
 * ResultCollection can implement some sort of iteration for batched pagination

can easily expand to other features.. 

 * single table inheritance
 * class table inheritance if someone is up for challenge</description>
		<content:encoded><![CDATA[<p>plus the concept code i just posted<br />
 * can be a lot faster with right engineering and optimizations<br />
 * all association are lazily loaded until its really called (without the mess we have lazy load all models, Containable + findAll)<br />
 * ResultCollection can implement some sort of iteration for batched pagination</p>
<p>can easily expand to other features.. </p>
<p> * single table inheritance<br />
 * class table inheritance if someone is up for challenge</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: speedmax</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-124411</link>
		<dc:creator>speedmax</dc:creator>
		<pubDate>Tue, 31 Mar 2009 02:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-124411</guid>
		<description>During my exploration trying to get a ActiveResource like base class implemented with better semantics 

 * static methods (class methods) used for table (collection) wide operations, new record, find
 * instance method use for row specific operation, delete, update

Well that requires to get static property and methods inheritance happening, some of the tricks i have included in this project i was contributing, that including fixing the late-static binding for PHP 5.1 and 5.2 

I have build a semi-prototype code demonstration the concept on how to make it possible to do a ActiveRecord-like base class with better static method inheritance in PHP 5.1 + 

Concept + demo code

http://gist.github.com/88016

a project i contributing (rubyism in php + magic) 

https://github.com/speedmax/phuby/tree</description>
		<content:encoded><![CDATA[<p>During my exploration trying to get a ActiveResource like base class implemented with better semantics </p>
<p> * static methods (class methods) used for table (collection) wide operations, new record, find<br />
 * instance method use for row specific operation, delete, update</p>
<p>Well that requires to get static property and methods inheritance happening, some of the tricks i have included in this project i was contributing, that including fixing the late-static binding for PHP 5.1 and 5.2 </p>
<p>I have build a semi-prototype code demonstration the concept on how to make it possible to do a ActiveRecord-like base class with better static method inheritance in PHP 5.1 + </p>
<p>Concept + demo code</p>
<p><a href="http://gist.github.com/88016" rel="nofollow">http://gist.github.com/88016</a></p>
<p>a project i contributing (rubyism in php + magic) </p>
<p><a href="https://github.com/speedmax/phuby/tree" rel="nofollow">https://github.com/speedmax/phuby/tree</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-90935</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sat, 24 May 2008 15:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-90935</guid>
		<description>@RainChen: Yes, you are right, enabling it by default leads to &quot;problems&quot; with baked code, I didn&#039;t consider that...

I think the clone method is a &quot;nice-to-have&quot; feature, it is not essential but in certain situations it can allow you to write cleaner code.</description>
		<content:encoded><![CDATA[<p>@RainChen: Yes, you are right, enabling it by default leads to &#8220;problems&#8221; with baked code, I didn&#8217;t consider that&#8230;</p>
<p>I think the clone method is a &#8220;nice-to-have&#8221; feature, it is not essential but in certain situations it can allow you to write cleaner code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RainChen</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-90759</link>
		<dc:creator>RainChen</dc:creator>
		<pubDate>Fri, 23 May 2008 17:57:57 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-90759</guid>
		<description>@cakebaker:

IMO, I will not change the default behaviors that Cake does. Such as Model::find() returning array datas by default and the associations eager loading. So I&#039;m prefer to give the users a choice and make sure they know what they are getting. Another reason, I use the bake command quite often for baking a quick admin interface, and the default baked codes will not working if returning an object.I don&#039;t want to give the users to much &quot;surprises&quot; by the error notices.

About the clone method, I just designed it for enabling users to add some alike data in a quick way. I&#039;m not sure if this method is necessary.</description>
		<content:encoded><![CDATA[<p>@cakebaker:</p>
<p>IMO, I will not change the default behaviors that Cake does. Such as Model::find() returning array datas by default and the associations eager loading. So I&#8217;m prefer to give the users a choice and make sure they know what they are getting. Another reason, I use the bake command quite often for baking a quick admin interface, and the default baked codes will not working if returning an object.I don&#8217;t want to give the users to much &#8220;surprises&#8221; by the error notices.</p>
<p>About the clone method, I just designed it for enabling users to add some alike data in a quick way. I&#8217;m not sure if this method is necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-90735</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 23 May 2008 15:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-90735</guid>
		<description>@RainChen: Looks very interesting and elegant :)  A really nice detail is the dynamic countXXX method. 

I&#039;m wondering about two things: is the enableActiveRecord() really necessary? I mean, if you add the ActiceRecord behavior then you probably want to use it, so I would enable it by default. 

The other point is the clone() method. I think it shouldn&#039;t allow parameters, as cloning is about creating an identical object. Or maybe the method should be named differently.

But all in all it looks very promising!</description>
		<content:encoded><![CDATA[<p>@RainChen: Looks very interesting and elegant :)  A really nice detail is the dynamic countXXX method. </p>
<p>I&#8217;m wondering about two things: is the enableActiveRecord() really necessary? I mean, if you add the ActiceRecord behavior then you probably want to use it, so I would enable it by default. </p>
<p>The other point is the clone() method. I think it shouldn&#8217;t allow parameters, as cloning is about creating an identical object. Or maybe the method should be named differently.</p>
<p>But all in all it looks very promising!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RainChen</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-90551</link>
		<dc:creator>RainChen</dc:creator>
		<pubDate>Thu, 22 May 2008 16:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-90551</guid>
		<description>@cakebaker:

I would like to hear some comments about this stuff:
http://pastie.caboo.se/200932</description>
		<content:encoded><![CDATA[<p>@cakebaker:</p>
<p>I would like to hear some comments about this stuff:<br />
<a href="http://pastie.caboo.se/200932" rel="nofollow">http://pastie.caboo.se/200932</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-86702</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sun, 04 May 2008 09:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-86702</guid>
		<description>@Kyle: That&#039;s possible with PHP (at least with PHP 5) by using the &quot;static&quot; keyword to make the method a class method:
&lt;pre&gt;
public static function findAll() {
    // this method is used like Post::findAll()
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Kyle: That&#8217;s possible with PHP (at least with PHP 5) by using the &#8220;static&#8221; keyword to make the method a class method:</p>
<pre>
public static function findAll() {
    // this method is used like Post::findAll()
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Slattery</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-86678</link>
		<dc:creator>Kyle Slattery</dc:creator>
		<pubDate>Sun, 04 May 2008 06:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-86678</guid>
		<description>It&#039;s too bad PHP doesn&#039;t support singleton functions (or maybe it does?).  It would be great to do something like:

$posts = Post::findAll();

And have each of the $posts be an instance of Post.  That way, the logic is separate, but it&#039;s still all contained within the same class.</description>
		<content:encoded><![CDATA[<p>It&#8217;s too bad PHP doesn&#8217;t support singleton functions (or maybe it does?).  It would be great to do something like:</p>
<p>$posts = Post::findAll();</p>
<p>And have each of the $posts be an instance of Post.  That way, the logic is separate, but it&#8217;s still all contained within the same class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/comment-page-1/#comment-85249</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sun, 27 Apr 2008 08:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596#comment-85249</guid>
		<description>@Doug: Yeah, it would be cool to have such a syntax in cake 2.0. 

@Tim: In retrospect I think the example in the article is not that good ;-)  I agree with you that it doesn&#039;t make much sense to create an object simply to call delete() on it. In such a situation it would be easier to call delete() at the table level. On the other hand there are also situations when it is more natural to call delete() on a record object. In the end it is up to the developer to choose the &quot;right&quot; method.</description>
		<content:encoded><![CDATA[<p>@Doug: Yeah, it would be cool to have such a syntax in cake 2.0. </p>
<p>@Tim: In retrospect I think the example in the article is not that good ;-)  I agree with you that it doesn&#8217;t make much sense to create an object simply to call delete() on it. In such a situation it would be easier to call delete() at the table level. On the other hand there are also situations when it is more natural to call delete() on a record object. In the end it is up to the developer to choose the &#8220;right&#8221; method.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
