<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cakebaker &#187; convention</title>
	<atom:link href="http://cakebaker.42dh.com/tags/convention/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>&#8220;updated&#8221; or &#8220;modified&#8221;</title>
		<link>http://cakebaker.42dh.com/2008/10/28/updated-or-modified/</link>
		<comments>http://cakebaker.42dh.com/2008/10/28/updated-or-modified/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 10:17:39 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=910</guid>
		<description><![CDATA[There are three columns which are automagically filled by CakePHP if they exist: &#8220;created&#8221;, &#8220;updated&#8221;, and &#8220;modified&#8221;. It is probably obvious that &#8220;created&#8221; is filled at the time a record gets inserted into the database. And &#8220;updated&#8221; and &#8220;modified&#8221; when a record is changed. But what&#8217;s the difference between &#8220;updated&#8221; and &#8220;modified&#8221;? Well, there is [...]]]></description>
			<content:encoded><![CDATA[<p>There are three columns which are automagically filled by CakePHP if they exist: &#8220;created&#8221;, &#8220;updated&#8221;, and &#8220;modified&#8221;. It is probably obvious that &#8220;created&#8221; is filled at the time a record gets inserted into the database. And &#8220;updated&#8221; and &#8220;modified&#8221; when a record is changed. </p>
<p>But what&#8217;s the difference between &#8220;updated&#8221; and &#8220;modified&#8221;? Well, there is none. You can either use &#8220;updated&#8221; or &#8220;modified&#8221;, just don&#8217;t use both as that is redundant. And whichever column name you choose, use it throughout your database to be consistent!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/10/28/updated-or-modified/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>What&#8217;s the benefit of the singular/plural conventions in CakePHP?</title>
		<link>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/</link>
		<comments>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 13:07:12 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=852</guid>
		<description><![CDATA[While reading the CakePHP books I recently reviewed here, a question emerged for which I don&#8217;t have an answer: what&#8217;s the benefit of the singular/plural conventions we have in CakePHP for me as a framework user? With singular/plural conventions I mean the following conventions every new baker has to learn while doing his first steps [...]]]></description>
			<content:encoded><![CDATA[<p>While reading the CakePHP books I recently reviewed here, a question emerged for which I don&#8217;t have an answer: what&#8217;s the benefit of the singular/plural conventions we have in CakePHP for me as a framework user?</p>
<p>With singular/plural conventions I mean the following conventions every new baker has to learn while doing his first steps with Cake:</p>
<ul>
<li>Table names are plural (e.g. posts, categories, request_tokens)</li>
<li>Model names are singular (e.g. Post, Category, RequestToken)</li>
<li>Controller names are plural and ending with &#8220;Controller&#8221; (e.g. PostsController, CategoriesController, RequestTokensController)</li>
</ul>
<p>I follow those conventions automatically, but I have to admit I don&#8217;t see any real advantages in the distinction between singular and plural names at the moment. On the other hand, the disadvantages are they only work if you use English names (else you have to define your own rules in app/config/inflections.php), they make the learning curve steeper, and if you look at tables as objects it is not that logical to use plural names for them&#8230; </p>
<p>Please don&#8217;t get me wrong, I think it is a good thing to have naming conventions, but I also think the current conventions could be simplified, to something like:</p>
<ul>
<li>Table names are singular (e.g. post, category, request_token)</li>
<li>Model names are like table names, but camel-cased (e.g. Post, Category, RequestToken)</li>
<li>Controller names use the model names plus &#8220;Controller&#8221; (e.g. PostController, CategoryController, RequestTokenController)</li>
</ul>
<p>You would get all the benefits of naming conventions without having to care whether a name has to be singular or plural. And the conventions would also work for people who prefer to use names in their native languages. </p>
<p>I know, those singular/plural conventions probably won&#8217;t disappear, as they are core conventions and a change would affect many Cake applications&#8230; At least I learned something about the design of conventions from this example ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/10/15/whats-the-benefit-of-the-singularplural-conventions-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>A missing convention</title>
		<link>http://cakebaker.42dh.com/2008/10/06/a-missing-convention/</link>
		<comments>http://cakebaker.42dh.com/2008/10/06/a-missing-convention/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 15:43:28 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[convention]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=874</guid>
		<description><![CDATA[In CakePHP we have many conventions which tell us where to place certain files: controllers are placed in app/controllers, models in app/models, views in app/views, and so on. Only for one category of files there is no (explicit) convention of where to place them: the files containing &#8220;normal&#8221; classes you want to use anywhere. According [...]]]></description>
			<content:encoded><![CDATA[<p>In CakePHP we have many conventions which tell us where to place certain files: controllers are placed in app/controllers, models in app/models, views in app/views, and so on. Only for one category of files there is no (explicit) convention of where to place them: the files containing &#8220;normal&#8221; classes you want to use anywhere.</p>
<p>According to a <a href="https://trac.cakephp.org/ticket/3525">comment</a> by gwoo those files should be placed in the vendors folder: &#8220;Vendors is fine. Any classes that are not part of the MVC are considered 3rd party classes.&#8221;</p>
<p>Sure, this works. Only, it means you have to mix two different concepts: on the one hand you have classes you get from someone else (the &#8220;vendor&#8221;) and which you usually don&#8217;t touch (and often don&#8217;t follow the Cake conventions), and on the other hand you develop your own non-MVC classes following the Cake conventions in the same folder. To me this doesn&#8217;t feel right&#8230;  </p>
<p>And so I think there should be a convention like &#8220;Non-MVC classes are placed in app/libs&#8221; to separate &#8220;internal&#8221; and &#8220;external&#8221; libs and to show in the &#8220;app&#8221; folder the fact that an application (often) consists of utility classes and external libraries. </p>
<p>Such a convention would also help to avoid comments like the following comment for a class defined in a AppModel: &#8220;q: Why is this in the app_model file? a: Because we couldn&#8217;t really think of a better place. Suggestions are most welcome.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/10/06/a-missing-convention/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Use a convention to structure your code</title>
		<link>http://cakebaker.42dh.com/2007/09/24/use-a-convention-to-structure-your-code/</link>
		<comments>http://cakebaker.42dh.com/2007/09/24/use-a-convention-to-structure-your-code/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 09:11:17 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/09/24/use-a-convention-to-structure-your-code/</guid>
		<description><![CDATA[One feature I like in Eclipse is the outline view which shows you the structure (i.e. the variables and methods) of the file you edit and allows you to jump quickly to those code elements (see image). To use this feature efficiently it makes sense to use a convention to structure your code (the example [...]]]></description>
			<content:encoded><![CDATA[<p>One feature I like in <a href="http://www.eclipse.org/pdt">Eclipse</a> is the outline view which shows you the structure (i.e. the variables and methods) of the file you edit and allows you to jump quickly to those code elements (see image). </p>
<p><img src='http://cakebaker.42dh.com/wp-content/uploads/2007/09/eclipse_outline.png' alt='Outline view' /></p>
<p>To use this feature efficiently it makes sense to use a convention to structure your code (the example in the image is unstructured hence it is more difficult to find a certain method). And even if your IDE doesn&#8217;t provide such a feature it makes sense to follow a convention as it makes your code more cleaner. </p>
<p>The convention I use is simple: first public stuff, then private stuff, both ordered alphabetically. So a CakePHP file may look like:</p>
<pre>
class A {
    var $a = ...
    var $z = ...
    var $__a = ...
    var $__z = ...

    function a() {}

    function z() {}

    function __a() {}

    function __z() {}
}
</pre>
<p>Especially if you have larger files it helps to avoid that you get a messy code structure. And it doesn&#8217;t require any additional effort. </p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/09/24/use-a-convention-to-structure-your-code/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

