<?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: A missing concept: model &#8220;components&#8221;</title>
	<atom:link href="http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Wed, 28 Jul 2010 19:06:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Garret</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-91169</link>
		<dc:creator>Garret</dc:creator>
		<pubDate>Sun, 25 May 2008 23:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-91169</guid>
		<description>&gt; I agree: if we already have Helpers and Components, why not 
&gt; have something similar for Models. Behaviors add a *behavior* to 
&gt; the model, i.e. responsibilities to that model. What if we want 
&gt; utility classes ?

@XR: EXACTLY</description>
		<content:encoded><![CDATA[<p>&gt; I agree: if we already have Helpers and Components, why not<br />
&gt; have something similar for Models. Behaviors add a *behavior* to<br />
&gt; the model, i.e. responsibilities to that model. What if we want<br />
&gt; utility classes ?</p>
<p>@XR: EXACTLY</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-90344</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 21 May 2008 17:42:11 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-90344</guid>
		<description>@Xr: Thanks for your comment, you worded it much better than I did ;-)</description>
		<content:encoded><![CDATA[<p>@Xr: Thanks for your comment, you worded it much better than I did ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xr</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-90202</link>
		<dc:creator>Xr</dc:creator>
		<pubDate>Wed, 21 May 2008 06:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-90202</guid>
		<description>the_woodsman: The interface forces you to implement some methods, it doesn&#039;t give a shared implementation but a shared API. Not what we&#039;re after, if I understood correctly.
Still, it is indeed of good practice in OOP to separate concerns.

I agree: if we already have Helpers and Components, why not have something similar for Models. Behaviors add a *behavior* to the model, i.e. responsibilities to that model. What if we want utility classes ?</description>
		<content:encoded><![CDATA[<p>the_woodsman: The interface forces you to implement some methods, it doesn&#8217;t give a shared implementation but a shared API. Not what we&#8217;re after, if I understood correctly.<br />
Still, it is indeed of good practice in OOP to separate concerns.</p>
<p>I agree: if we already have Helpers and Components, why not have something similar for Models. Behaviors add a *behavior* to the model, i.e. responsibilities to that model. What if we want utility classes ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-89395</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sun, 18 May 2008 08:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-89395</guid>
		<description>@Felix: A simple example: a method to format data (e.g. a date) in a certain way. But in principle you can take any method you make private in your model as a potential use case.

@the_woodsman: Yes, it is the same principle, only in a different context.

Hm, I don&#039;t understand your idea with the interface :&#124; With an interface you define a public API, so I don&#039;t see how you could hide something by using an interface.</description>
		<content:encoded><![CDATA[<p>@Felix: A simple example: a method to format data (e.g. a date) in a certain way. But in principle you can take any method you make private in your model as a potential use case.</p>
<p>@the_woodsman: Yes, it is the same principle, only in a different context.</p>
<p>Hm, I don&#8217;t understand your idea with the interface :| With an interface you define a public API, so I don&#8217;t see how you could hide something by using an interface.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: the_woodsman</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-89346</link>
		<dc:creator>the_woodsman</dc:creator>
		<pubDate>Sun, 18 May 2008 01:12:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-89346</guid>
		<description>&gt; However, adding shared functionality 
&gt; between models 
&gt; but hiding it from your controllers 
&gt; makes little to know sense.

Erm, isn&#039;t this akin to a protected method/field in a parent class? 
If it&#039;s a core part of OO languages, I think it&#039;s probably a good idea: it makes good sense to only expose a well chosen public API.

PHP doesn&#039;t support multiple inheritence, so as mentioned, a  composition pattern is essential to the whole concept.

Could you not achieve similar using an interface (PHP5 only, so not for the cake core obv), i.e your models implement the interfaces, and your controllers can check if they have?</description>
		<content:encoded><![CDATA[<p>&gt; However, adding shared functionality<br />
&gt; between models<br />
&gt; but hiding it from your controllers<br />
&gt; makes little to know sense.</p>
<p>Erm, isn&#8217;t this akin to a protected method/field in a parent class?<br />
If it&#8217;s a core part of OO languages, I think it&#8217;s probably a good idea: it makes good sense to only expose a well chosen public API.</p>
<p>PHP doesn&#8217;t support multiple inheritence, so as mentioned, a  composition pattern is essential to the whole concept.</p>
<p>Could you not achieve similar using an interface (PHP5 only, so not for the cake core obv), i.e your models implement the interfaces, and your controllers can check if they have?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felix Geisendörfer</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-89265</link>
		<dc:creator>Felix Geisendörfer</dc:creator>
		<pubDate>Sat, 17 May 2008 16:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-89265</guid>
		<description>Daniel: I don&#039;t get it. I see the problem with all behaviors affecting the Model API, but that can easily be worked around by Overloading your behavior, and making its instance available to your Model during the setup process and then dispatching calls on it to private methods inside your behavior. However, adding shared functionality between models but hiding it from your controllers makes little to know sense. Do you have an actual usage case for that?</description>
		<content:encoded><![CDATA[<p>Daniel: I don&#8217;t get it. I see the problem with all behaviors affecting the Model API, but that can easily be worked around by Overloading your behavior, and making its instance available to your Model during the setup process and then dispatching calls on it to private methods inside your behavior. However, adding shared functionality between models but hiding it from your controllers makes little to know sense. Do you have an actual usage case for that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-89175</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sat, 17 May 2008 07:51:43 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-89175</guid>
		<description>@Mariano: I&#039;m not sure you understand what I want to accomplish.   I want to share model functionality between models without making the shared functionality available for controllers. If I add a (public) method to a behavior, then I can access it from models *and* controllers. If I make this method protected or private, I can access it neither from models nor controllers. You see the problem?

@Garret: Thanks for your long comment and the clarifications!

I have chosen the name &quot;model components&quot; to show it is a very similar concept to the concept of &quot;controller components&quot;. But maybe it would be better to use a different name...

Yes, you are right, I&#039;m looking for the best most elegant way to do it, and not for a workaround to accomplish (almost) the same.

The same here, I don&#039;t like to mess with the structure of the cake core, and so I keep using the solution with the &quot;vendors&quot; folder. And yes, it would be cool to have it implemented in the core :)</description>
		<content:encoded><![CDATA[<p>@Mariano: I&#8217;m not sure you understand what I want to accomplish.   I want to share model functionality between models without making the shared functionality available for controllers. If I add a (public) method to a behavior, then I can access it from models *and* controllers. If I make this method protected or private, I can access it neither from models nor controllers. You see the problem?</p>
<p>@Garret: Thanks for your long comment and the clarifications!</p>
<p>I have chosen the name &#8220;model components&#8221; to show it is a very similar concept to the concept of &#8220;controller components&#8221;. But maybe it would be better to use a different name&#8230;</p>
<p>Yes, you are right, I&#8217;m looking for the best most elegant way to do it, and not for a workaround to accomplish (almost) the same.</p>
<p>The same here, I don&#8217;t like to mess with the structure of the cake core, and so I keep using the solution with the &#8220;vendors&#8221; folder. And yes, it would be cool to have it implemented in the core :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mariano Iglesias</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-88993</link>
		<dc:creator>Mariano Iglesias</dc:creator>
		<pubDate>Fri, 16 May 2008 13:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-88993</guid>
		<description>@Garrett: I don&#039;t get it, did you read the comments? What are behaviors then??</description>
		<content:encoded><![CDATA[<p>@Garrett: I don&#8217;t get it, did you read the comments? What are behaviors then??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garret</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-88884</link>
		<dc:creator>Garret</dc:creator>
		<pubDate>Fri, 16 May 2008 00:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-88884</guid>
		<description>hmm, your input filter removed some of my example code</description>
		<content:encoded><![CDATA[<p>hmm, your input filter removed some of my example code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garret</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/comment-page-1/#comment-88883</link>
		<dc:creator>Garret</dc:creator>
		<pubDate>Fri, 16 May 2008 00:40:40 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603#comment-88883</guid>
		<description>Well I for one agree with you.

I&#039;ve been in many situations where I wished there were components available to load into your model just as easily as you can for controllers. You don&#039;t necessarily even have to call them components, you could call them, say, extensions, processors, plugins? I dunno, something that indicates that they&#039;re not part of the actual model, but will work inside the model for processing purposes and is protected from outside forces i.e. the controller and view.

I don&#039;t think you&#039;re trying to understand how to get it to work, as I know you probably understand completely how to import files and/or use Snook&#039;s class inheritance solution. You&#039;re looking for the best most elegant way to do it, and I think you&#039;ve hit it on the head.

Putting everything in AppModel is definitely dirty. I also think Snook&#039;s solution is dirty, he says so himself, and can get very complicated very quickly if you have a large model structure. It would be easier if you could just load a component into your model, just like you can controllers.

Example:

Component-&gt;action($this-&gt;data);
...

}
?&gt;

(I know this is a bit of a reiteration of what you wrote, it just adds a little bit for clarity)

So, anyways, I think you&#039;re right, and I don&#039;t want to mess with the structure of the cake core too much since I like being able to keep current for bug fixes, so I kind of have to live with it for now. However, I think it would be fantastic if this were implemented in the core.</description>
		<content:encoded><![CDATA[<p>Well I for one agree with you.</p>
<p>I&#8217;ve been in many situations where I wished there were components available to load into your model just as easily as you can for controllers. You don&#8217;t necessarily even have to call them components, you could call them, say, extensions, processors, plugins? I dunno, something that indicates that they&#8217;re not part of the actual model, but will work inside the model for processing purposes and is protected from outside forces i.e. the controller and view.</p>
<p>I don&#8217;t think you&#8217;re trying to understand how to get it to work, as I know you probably understand completely how to import files and/or use Snook&#8217;s class inheritance solution. You&#8217;re looking for the best most elegant way to do it, and I think you&#8217;ve hit it on the head.</p>
<p>Putting everything in AppModel is definitely dirty. I also think Snook&#8217;s solution is dirty, he says so himself, and can get very complicated very quickly if you have a large model structure. It would be easier if you could just load a component into your model, just like you can controllers.</p>
<p>Example:</p>
<p>Component-&gt;action($this-&gt;data);<br />
&#8230;</p>
<p>}<br />
?&gt;</p>
<p>(I know this is a bit of a reiteration of what you wrote, it just adds a little bit for clarity)</p>
<p>So, anyways, I think you&#8217;re right, and I don&#8217;t want to mess with the structure of the cake core too much since I like being able to keep current for bug fixes, so I kind of have to live with it for now. However, I think it would be fantastic if this were implemented in the core.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
