<?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: What&#8217;s the benefit of the singular/plural conventions in CakePHP?</title>
	<atom:link href="http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:27:01 +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/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-111008</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 22 Oct 2008 15:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-111008</guid>
		<description>@bob: Thanks for your questions!

From my answer to Rafael: &quot;I don’t think we should have a convention of appending “Model” to model names. Models represent concepts of the problem domain, and so it doesn’t make much sense to have names like UserModel, because you will find a User in the problem domain, not a UserModel…&quot; 

On the other hand I think it makes sense to append &quot;Controller&quot; to controllers, as it describes the role of those classes. 

But I know, cake is not that consistent with the naming conventions at the file level. The UsersController class is in a file users_controller.php whereas the class FormHelper is in the file form.php (and not in form_helper.php). Personally I would prefer to have a convention which says: the filename is like the class name, but underscored.

I&#039;m not sure what you mean with your last question. Camel case names are used everywhere with the exception of table and file names. And there I think it makes sense to use underscored names, as it is a common practice. 

Hope that answers your questions!</description>
		<content:encoded><![CDATA[<p>@bob: Thanks for your questions!</p>
<p>From my answer to Rafael: &#8220;I don’t think we should have a convention of appending “Model” to model names. Models represent concepts of the problem domain, and so it doesn’t make much sense to have names like UserModel, because you will find a User in the problem domain, not a UserModel…&#8221; </p>
<p>On the other hand I think it makes sense to append &#8220;Controller&#8221; to controllers, as it describes the role of those classes. </p>
<p>But I know, cake is not that consistent with the naming conventions at the file level. The UsersController class is in a file users_controller.php whereas the class FormHelper is in the file form.php (and not in form_helper.php). Personally I would prefer to have a convention which says: the filename is like the class name, but underscored.</p>
<p>I&#8217;m not sure what you mean with your last question. Camel case names are used everywhere with the exception of table and file names. And there I think it makes sense to use underscored names, as it is a common practice. </p>
<p>Hope that answers your questions!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110985</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Wed, 22 Oct 2008 10:51:16 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110985</guid>
		<description>A non &quot;plural vs singular&quot; question...

If you have NamesController.php, why not NameModel.php?  Or just Name(s).php in the controllers/models folder?

Why do we use camel case only some of the time?</description>
		<content:encoded><![CDATA[<p>A non &#8220;plural vs singular&#8221; question&#8230;</p>
<p>If you have NamesController.php, why not NameModel.php?  Or just Name(s).php in the controllers/models folder?</p>
<p>Why do we use camel case only some of the time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110851</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Tue, 21 Oct 2008 11:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110851</guid>
		<description>@cakebaker: no, you actually putted it very well - as usually - and I had changed my mind about the prefixing stuff... ;-)</description>
		<content:encoded><![CDATA[<p>@cakebaker: no, you actually putted it very well &#8211; as usually &#8211; and I had changed my mind about the prefixing stuff&#8230; ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110733</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 20 Oct 2008 15:30:14 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110733</guid>
		<description>@Mark: Thanks for your comment!

Yes, that&#039;s true, there are two different camps regarding this topic. The article &lt;a href=&quot;http://www.breaksoft.com/Blog/Posts/2004/9/Plural_vs_Singular_Table_Names.aspx&quot; rel=&quot;nofollow&quot;&gt;Plural vs Singular Table Names&lt;/a&gt; lists the advantages of both approaches.</description>
		<content:encoded><![CDATA[<p>@Mark: Thanks for your comment!</p>
<p>Yes, that&#8217;s true, there are two different camps regarding this topic. The article <a href="http://www.breaksoft.com/Blog/Posts/2004/9/Plural_vs_Singular_Table_Names.aspx" rel="nofollow">Plural vs Singular Table Names</a> lists the advantages of both approaches.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Story</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110589</link>
		<dc:creator>Mark Story</dc:creator>
		<pubDate>Sat, 18 Oct 2008 15:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110589</guid>
		<description>Singular table names don&#039;t really sit well with me, they are storage areas for multiple objects, so plural form makes sense.  As for model names staying singular I agree with this as well.  For the most part it acts as a single object, and often represents a single row.  There are many model methods that work on multiple rows, but that doesn&#039;t diminish the fact that their most common use (at least for me) is to work on a single row at a time.  It would be painful in the long run to require a convention like &lt;code&gt;$this-&gt;Post-&gt;all-&gt;find($conditions);&lt;/code&gt;.  Controllers represent ways to access all objects of a similar type, so again plural makes sense.  At the end of the day its very much a tomato/tomatoe discussion.  There are plenty of arguments on both sides, and cake has just chosen one of those sides.</description>
		<content:encoded><![CDATA[<p>Singular table names don&#8217;t really sit well with me, they are storage areas for multiple objects, so plural form makes sense.  As for model names staying singular I agree with this as well.  For the most part it acts as a single object, and often represents a single row.  There are many model methods that work on multiple rows, but that doesn&#8217;t diminish the fact that their most common use (at least for me) is to work on a single row at a time.  It would be painful in the long run to require a convention like <code>$this-&gt;Post-&gt;all-&gt;find($conditions);</code>.  Controllers represent ways to access all objects of a similar type, so again plural makes sense.  At the end of the day its very much a tomato/tomatoe discussion.  There are plenty of arguments on both sides, and cake has just chosen one of those sides.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110494</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 17 Oct 2008 15:09:41 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110494</guid>
		<description>@Rafael, Joe: Thanks for your comments!

@Rafael: Personally I don&#039;t like the prefixing, too. But if you want to avoid naming conflicts you either need such a prefix in the framework or a convention for the framework users (at least as long there is no support for namespaces). The advantage of the prefix is it affects only a few people (the framework developers), whereas in the other case it affects all framework users.

I don&#039;t think we should have a convention of appending &quot;Model&quot; to model names. Models represent concepts of the problem domain, and so it doesn&#039;t make much sense to have names like UserModel, because you will find a User in the problem domain, not a UserModel... On the other hand it is ok to append the type to the names of the other &quot;components&quot; because those &quot;components&quot; represent abstract software concepts you won&#039;t find in a problem domain. 

Hope that&#039;s not too abstract ;-)

@Joe: No, it wouldn&#039;t make your code more readable, a class name like &quot;UserController&quot; is as readable as the current &quot;UsersController&quot; in my opinion.</description>
		<content:encoded><![CDATA[<p>@Rafael, Joe: Thanks for your comments!</p>
<p>@Rafael: Personally I don&#8217;t like the prefixing, too. But if you want to avoid naming conflicts you either need such a prefix in the framework or a convention for the framework users (at least as long there is no support for namespaces). The advantage of the prefix is it affects only a few people (the framework developers), whereas in the other case it affects all framework users.</p>
<p>I don&#8217;t think we should have a convention of appending &#8220;Model&#8221; to model names. Models represent concepts of the problem domain, and so it doesn&#8217;t make much sense to have names like UserModel, because you will find a User in the problem domain, not a UserModel&#8230; On the other hand it is ok to append the type to the names of the other &#8220;components&#8221; because those &#8220;components&#8221; represent abstract software concepts you won&#8217;t find in a problem domain. </p>
<p>Hope that&#8217;s not too abstract ;-)</p>
<p>@Joe: No, it wouldn&#8217;t make your code more readable, a class name like &#8220;UserController&#8221; is as readable as the current &#8220;UsersController&#8221; in my opinion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joe siao</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110475</link>
		<dc:creator>joe siao</dc:creator>
		<pubDate>Fri, 17 Oct 2008 11:07:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110475</guid>
		<description>Hi,

I don&#039;t know if using this type of convention would help me making my code more readable too... or is it even relevant...?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I don&#8217;t know if using this type of convention would help me making my code more readable too&#8230; or is it even relevant&#8230;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110429</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Fri, 17 Oct 2008 00:52:56 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110429</guid>
		<description>I don&#039;t like the idea of having &quot;Cake&quot; prepended to core classes as it would turn things much more verborragic and ugly. I don&#039;t like namespaced names and I think the take a lot of readability of the code
&lt;code&gt;
$this-&gt;File-&gt;append($text);
// is much more intuitive than
$this-&gt;CakeFile-&gt;append($text);
&lt;/code&gt;
And it&#039;s certainly the kind of stuff that takes me away of frameworks like Symfony and ZF, it makes things look &quot;unatural&quot;... dealing with core classes of cake you feel at home, with auto explanatory names that gives lots of fluidability to the code you&#039;re writing.
Now, having &quot;Model&quot; appended to model&#039;s name is the missing convention, after all, all other cake&#039;s mvc components have their types appended to their name.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like the idea of having &#8220;Cake&#8221; prepended to core classes as it would turn things much more verborragic and ugly. I don&#8217;t like namespaced names and I think the take a lot of readability of the code<br />
<pre><code>$this-&gt;File-&gt;append($text);
// is much more intuitive than
$this-&gt;CakeFile-&gt;append($text);</code></pre><br />
And it&#8217;s certainly the kind of stuff that takes me away of frameworks like Symfony and ZF, it makes things look &#8220;unatural&#8221;&#8230; dealing with core classes of cake you feel at home, with auto explanatory names that gives lots of fluidability to the code you&#8217;re writing.<br />
Now, having &#8220;Model&#8221; appended to model&#8217;s name is the missing convention, after all, all other cake&#8217;s mvc components have their types appended to their name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110398</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 16 Oct 2008 17:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110398</guid>
		<description>@all: Thanks for your comments!

@nate: Yes. There are usually some triggers which force me to look at something. In this case the triggers were the books and my experiments with MySQL Workbench.

@Andreas: Yes, those words are keywords and shouldn&#039;t be used as table names (even though it is possible to use them). 

I think it depends on your point of view whether a table name should be singular or plural. If you see a table as a container for &quot;objects&quot;, then it probably makes sense to use plural names. 

On the other hand, on a more abstract level, isn&#039;t there a table just a different representation of a model? If you model a &quot;concept&quot; (e.g. a user) in a ER diagram it looks almost the same as if you model it in a UML diagram. In both cases it represents the concept &quot;user&quot;, which defines, for example, that a user has a username and a password. And as there is only one user concept, it makes sense to use singular names.

@Aeron: See my answer to Andreas. 

I&#039;m not sure whether &quot;Controller&quot; should be removed, personally I appended it to controller classes before I used cake when there was no such convention. In the early cake days there was some discussion about removing it, but in the end it was decided to keep it (see &lt;a href=&quot;https://trac.cakephp.org/ticket/121&quot; rel=&quot;nofollow&quot;&gt;ticket 121&lt;/a&gt;).

I agree that the ACL column names are a bit ugly, but I think &quot;lt&quot; and &quot;rt&quot; are not much better ;-)

@Jonathan: Hm, I think appending &quot;Model&quot; to model classes to avoid naming collisions is the wrong approach. IMO it would be better to add a &quot;Cake&quot; prefix to the core classes.

@Michal: Yes, those naming conventions have been borrowed from Rails. Cake uses the same philosophies (convention over configuration) as Rails, but else it is going its own way.

@Khaled: Well, you find both conventions in use.

@Jonah: Yes, it is a little bit more readable if you use plural names. On the other hand, cake adds a singular alias to it when executing such statements, so you have SELECT * FROM posts AS Post vs. SELECT * FROM post AS Post, in which case I think the second statement is more readable ;-)

@Phally: I disagree, see my answer to Andreas.

@JMG: Yes, from a logical point of view it would make sense to have two classes: one representing the table, and one representing a single record. But I don&#039;t know if it would be practical...

@Martin: At least to me, a model represents a &quot;concept&quot;, e.g. an article, and not a collection. And so it should have a singular name, see also my answer to Andreas. 

@Nik: Sure, it makes your life easier if you follow the conventions, on the other hand conventions are not fix and can change over time. 

@NOSLOW: Yes, that&#039;s the advantage of naming conventions and what I like about them. But I also think it makes sense to question the conventions from time to time, as conventions are not fix.</description>
		<content:encoded><![CDATA[<p>@all: Thanks for your comments!</p>
<p>@nate: Yes. There are usually some triggers which force me to look at something. In this case the triggers were the books and my experiments with MySQL Workbench.</p>
<p>@Andreas: Yes, those words are keywords and shouldn&#8217;t be used as table names (even though it is possible to use them). </p>
<p>I think it depends on your point of view whether a table name should be singular or plural. If you see a table as a container for &#8220;objects&#8221;, then it probably makes sense to use plural names. </p>
<p>On the other hand, on a more abstract level, isn&#8217;t there a table just a different representation of a model? If you model a &#8220;concept&#8221; (e.g. a user) in a ER diagram it looks almost the same as if you model it in a UML diagram. In both cases it represents the concept &#8220;user&#8221;, which defines, for example, that a user has a username and a password. And as there is only one user concept, it makes sense to use singular names.</p>
<p>@Aeron: See my answer to Andreas. </p>
<p>I&#8217;m not sure whether &#8220;Controller&#8221; should be removed, personally I appended it to controller classes before I used cake when there was no such convention. In the early cake days there was some discussion about removing it, but in the end it was decided to keep it (see <a href="https://trac.cakephp.org/ticket/121" rel="nofollow">ticket 121</a>).</p>
<p>I agree that the ACL column names are a bit ugly, but I think &#8220;lt&#8221; and &#8220;rt&#8221; are not much better ;-)</p>
<p>@Jonathan: Hm, I think appending &#8220;Model&#8221; to model classes to avoid naming collisions is the wrong approach. IMO it would be better to add a &#8220;Cake&#8221; prefix to the core classes.</p>
<p>@Michal: Yes, those naming conventions have been borrowed from Rails. Cake uses the same philosophies (convention over configuration) as Rails, but else it is going its own way.</p>
<p>@Khaled: Well, you find both conventions in use.</p>
<p>@Jonah: Yes, it is a little bit more readable if you use plural names. On the other hand, cake adds a singular alias to it when executing such statements, so you have SELECT * FROM posts AS Post vs. SELECT * FROM post AS Post, in which case I think the second statement is more readable ;-)</p>
<p>@Phally: I disagree, see my answer to Andreas.</p>
<p>@JMG: Yes, from a logical point of view it would make sense to have two classes: one representing the table, and one representing a single record. But I don&#8217;t know if it would be practical&#8230;</p>
<p>@Martin: At least to me, a model represents a &#8220;concept&#8221;, e.g. an article, and not a collection. And so it should have a singular name, see also my answer to Andreas. </p>
<p>@Nik: Sure, it makes your life easier if you follow the conventions, on the other hand conventions are not fix and can change over time. </p>
<p>@NOSLOW: Yes, that&#8217;s the advantage of naming conventions and what I like about them. But I also think it makes sense to question the conventions from time to time, as conventions are not fix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NOSLOW</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/comment-page-1/#comment-110380</link>
		<dc:creator>NOSLOW</dc:creator>
		<pubDate>Thu, 16 Oct 2008 13:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852#comment-110380</guid>
		<description>What I like about using conventions is that I don&#039;t have to waste any time thinking (arguing in my head) about stuff like whether something should be singular or plural. Sure you could argue all day long about why is should be this way vs. that way. Pick one, move on and don&#039;t second guess it. Just go with it. Or else you&#039;re wasting time that conventions saves you in the first place.</description>
		<content:encoded><![CDATA[<p>What I like about using conventions is that I don&#8217;t have to waste any time thinking (arguing in my head) about stuff like whether something should be singular or plural. Sure you could argue all day long about why is should be this way vs. that way. Pick one, move on and don&#8217;t second guess it. Just go with it. Or else you&#8217;re wasting time that conventions saves you in the first place.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
