<?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; ideas</title>
	<atom:link href="http://cakebaker.42dh.com/tags/ideas/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:23:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>An idea for improving CakePHP&#8217;s ACL system</title>
		<link>http://cakebaker.42dh.com/2009/02/26/an-idea-for-improving-cakephps-acl-system/</link>
		<comments>http://cakebaker.42dh.com/2009/02/26/an-idea-for-improving-cakephps-acl-system/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 16:08:40 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[acl]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1107</guid>
		<description><![CDATA[Recently, I stumbled upon an article about ACL in the Zend framework, written by Jani Hartikainen. While reading it, I realized that probably many people struggle with CakePHP&#8217;s ACL because of the naming. The main classes of CakePHP&#8217;s ACL implementation are named ACO and ARO, which are acronyms for the technical terms &#8220;access control object&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I stumbled upon an <a href="http://codeutopia.net/blog/2009/02/06/zend_acl-part-1-misconceptions-and-simple-acls/">article about ACL in the Zend framework</a>, written by Jani Hartikainen. While reading it, I realized that probably many people struggle with CakePHP&#8217;s ACL because of the naming.</p>
<p>The main classes of CakePHP&#8217;s ACL implementation are named ACO and ARO, which are acronyms for the technical terms &#8220;access control object&#8221; and &#8220;access request object&#8221;. An access control object is something that gets accessed, whereas an access request object is something that wants to access an access control object. </p>
<p>As those acronyms are probably not that familiar to most (I heard them for the first time with the introduction of the ACL feature), you always have to perform translations when you read/hear &#8220;ACO&#8221; or &#8220;ARO&#8221;:</p>
<pre>
<code>ACO =&gt; Access Control Object =&gt; term you are familiar with
ARO =&gt; Access Request Object =&gt; term you are familiar with</code>
</pre>
<p>After a while you (resp. your brain) will make those translations automatically. However, at the beginning, when you try to grasp CakePHP&#8217;s ACL implementation, those translation automatisms are not there yet, which makes the understanding more difficult&#8230;</p>
<p>Now compare this with the names used in the Zend framework: Zend_Acl_Resource (= ACO) and Zend_Acl_Role (= ARO). At least to me those names sound quite familiar. They are very similar to the terms I would use in a discussion about authorization. And because of this familiarity, the aforementioned translation process can be omitted. </p>
<p>And so I think it would also make sense for CakePHP to use terms like &#8220;resource&#8221; and &#8220;role&#8221; instead of ACO and ARO to make it easier for those who want to learn how the ACL feature works. </p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/02/26/an-idea-for-improving-cakephps-acl-system/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>An idea for hacking core helpers</title>
		<link>http://cakebaker.42dh.com/2008/11/07/an-idea-for-hacking-core-helpers/</link>
		<comments>http://cakebaker.42dh.com/2008/11/07/an-idea-for-hacking-core-helpers/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 09:14:51 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=936</guid>
		<description><![CDATA[In a recent comment by John I got asked whether there is a way to override a method of a core helper like HtmlHelper::link() without affecting the variables in the views (i.e. you can still use $html-&#62;link() instead of $myHtml-&#62;link()). There are at least two approaches to accomplish this (without touching core files). The first [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent <a href="http://cakebaker.42dh.com/2008/10/18/dont-abuse-the-apphelper-to-extend-the-core-helpers/#comment-111961">comment</a> by <a href="http://www.flipflops.org">John</a> I got asked whether there is a way to override a method of a core helper like HtmlHelper::link() without affecting the variables in the views (i.e. you can still use $html-&gt;link() instead of $myHtml-&gt;link()). There are at least two approaches to accomplish this (without touching core files).</p>
<p>The first approach is to copy the HtmlHelper from the core (cake/libs/view/helpers/html.php) to the helpers folder of your application (app/views/helpers). And then you can modify this file as you like. Easy. The problem of this approach is the code duplication. If something in the core HtmlHelper is changed by the developers you have to reapply the changes in your own HtmlHelper&#8230;</p>
<p>The second approach is to replace the HtmlHelper with your own helper that extends the HtmlHelper. For this purpose you have to create a custom view class which overrides the _loadHelpers() method of the View. It&#8217;s probably best if I do a simple example to show the idea. </p>
<p>First we create our own helper:</p>
<pre>
<code>// app/views/helpers/example.php
App::import('Helper', 'Html');
class ExampleHelper extends HtmlHelper {
    public function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true) {
        return '&lt;a href="http://example.com"&gt;example&lt;/a&gt;';
    }
}</code>
</pre>
<p>Next, we create our custom view class:</p>
<pre>
<code>// app/views/example.php
class ExampleView extends View {
    public function &amp;_loadHelpers(&amp;$loaded, $helpers, $parent = null) {
        $loaded = parent::_loadHelpers($loaded, $helpers, $parent);
        $helper = 'Html';
		
        if (isset($loaded[$helper])) {
            App::import('Helper', 'Example');
            $loaded[$helper] = new ExampleHelper();
	
            // everything from here on is copied from View::_loadHelpers()
		
            $vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin');
            $c = count($vars);

            for ($j = 0; $j &lt; $c; $j++) {
                $loaded[$helper]-&gt;{$vars[$j]} = $this-&gt;{$vars[$j]};
            }

            if (!empty($this-&gt;validationErrors)) {
                $loaded[$helper]-&gt;validationErrors = $this-&gt;validationErrors;
            }

            if (is_array($loaded[$helper]-&gt;helpers) &amp;&amp; !empty($loaded[$helper]-&gt;helpers)) {
                $loaded =&amp; $this-&gt;_loadHelpers($loaded, $loaded[$helper]-&gt;helpers, $helper);
            }
        }
		
        return $loaded;
    }
}</code>
</pre>
<p>You probably wonder why I override _loadHelpers() and not _loadHelper(). Well, the reason is simple, there is no _loadHelper() method in the View class. And so I have to copy the code to setup a helper from the parent method. Not very clean, I know&#8230;</p>
<p>The last step is to specify that we want to use the view class we created above. We can do this in the AppController with:</p>
<pre>
<code>// app/app_controller.php
class AppController extends Controller {
    public $view = 'Example';
}</code>
</pre>
<p>Now, all links in our views should point to example.com. </p>
<p>The obvious disadvantage of this approach is that it is a hack ;-)  And I&#8217;m not sure whether it works to 100%. Use it on your own risk!</p>
<p>Personally, I would like to see the approach described by grigri (see his <a href="http://cakebaker.42dh.com/2008/10/18/dont-abuse-the-apphelper-to-extend-the-core-helpers/#comment-110708">comment</a>) in the core (or something similar): &#8220;It would be great if the cake helpers were really named &#8216;BaseHtmlHelper&#8217; with an empty class &#8216;HtmlHelper&#8217; which is loaded from the cake folder if not present in the app folder.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/11/07/an-idea-for-hacking-core-helpers/feed/</wfw:commentRss>
		<slash:comments>19</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>25</slash:comments>
		</item>
		<item>
		<title>An idea for loading helpers in the view</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/</link>
		<comments>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 15:20:15 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724</guid>
		<description><![CDATA[In the comments to my previous article, &#8220;An alternative to requestAction&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them in views. (Thanks to Rafael Bandeira and Tarique Sani) That&#8217;s indeed a bit illogical if you think about it. It would be more logical to define the [...]]]></description>
			<content:encoded><![CDATA[<p>In the comments to my previous article, &#8220;<a href="http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/">An alternative to requestAction</a>&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them in views. (Thanks to <a href="http://rafaelbandeira3.wordpress.com/">Rafael Bandeira</a> and <a href="http://www.sanisoft.com/blog/author/tariquesani/">Tarique Sani</a>)</p>
<p>That&#8217;s indeed a bit illogical if you think about it. It would be more logical to define the helpers directly where they are needed, in the views.</p>
<p>After some experimenting and digging in the source of the View class I found a relatively clean way to accomplish that by using a custom view class. </p>
<p>Ok, here is what I did. First I created a custom view class called &#8220;AppView&#8221; in app/views/app.php. It contains one method to load the helpers, which is later used in the views. I also had to override the constructor to support &#8220;global&#8221; helpers (i.e. they can be used in all views). So instead of defining them in the AppController they are now defined in the $helpers array of this custom view. FormHelper, HtmlHelper, and SessionHelper do not have to be defined, they are automatically loaded by CakePHP.</p>
<pre>
<code>// app/views/app.php
class AppView extends View {
    public $helpers = array('Navigation');
	
    public function __construct(&amp;$controller, $register = true) {
        $globalHelpers = $this-&gt;helpers;
        parent::__construct($controller, $register);
        $this-&gt;loadHelpers(array_merge($this-&gt;helpers, $globalHelpers));
    }
	
    public function loadHelpers($helperNames) {
        $helpers = $this-&gt;_loadHelpers($this-&gt;loaded, $helperNames);

        foreach ($helpers as $helper) {
            $name = str_replace('Helper', '', get_class($helper));
            $this-&gt;$name = $helper;
        }
    }
}</code>
</pre>
<p>To use this custom view class, I have to tell the AppController to do so by setting the $view property:</p>
<pre>
<code>// app/app_controller.php
class AppController extends Controller {
    public $view = 'App';
    ...
}</code>
</pre>
<p>And finally I can load and use the desired helpers in the views like:</p>
<pre>
<code>&lt;?php 
$this-&gt;loadHelpers(array('CamelCase')); 
echo $this-&gt;CamelCase-&gt;getSomething();
echo $this-&gt;Form-&gt;create('MyModel');
...
?&gt;</code>
</pre>
<p>As you can see from the example above, the usage of the helpers is different from what you are used to. Instead of $form-&gt;create() I used $this-&gt;Form-&gt;create(). It&#8217;s more to write, but I think it is more consistent with the rest of the framework. </p>
<p>What do you think about this approach?</p>
<p>Update (2008-08-28): Thanks to Rafael Bandeira&#8217;s idea it is no longer necessary to call the loadHelpers() method in your views, just copy the following method to the AppView and it will auto-load the helpers when they are needed:</p>
<pre>
<code>public function __get($property) {
    $this-&gt;loadHelpers(array($property));
    return $this-&gt;{$property};
}</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>An alternative approach for static pages</title>
		<link>http://cakebaker.42dh.com/2008/06/18/an-alternative-approach-for-static-pages/</link>
		<comments>http://cakebaker.42dh.com/2008/06/18/an-alternative-approach-for-static-pages/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 09:21:14 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=615</guid>
		<description><![CDATA[A while ago Jonathan Snook showed in the article Easier static pages with CakePHP 1.2 how you can easily create static pages by creating view files without corresponding controller actions. For this purpose he wrote a custom error handler. The &#8220;problem&#8221; of this approach is that an error handler is meant to show error messages, [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago <a href="http://snook.ca/jonathan">Jonathan Snook</a> showed in the article <a href="http://snook.ca/archives/cakephp/static_pages_cakephp12/">Easier static pages with CakePHP 1.2</a> how you can easily create static pages by creating view files without corresponding controller actions. For this purpose he wrote a custom error handler. The &#8220;problem&#8221; of this approach is that an error handler is meant to show error messages, and not static pages&#8230;</p>
<p>And so I looked for a different approach and ended up with a modified PagesController, combined with a route. The idea is to use the convention that each file in app/views/pages can be accessed like example.com/file (i.e. about.ctp is accessed as example.com/about and about/company.ctp as example.com/about/company). </p>
<p>Here is the PagesController:</p>
<pre>
// app/controllers/pages_controller.php
class PagesController extends AppController{
    public $uses = array();

    public function display() {
        $viewFilename = array_pop($this-&gt;params['pass']) . '.ctp';
        $viewFilename = str_replace('-', '_', $viewFilename);

        $viewPath =  DS . $viewFilename;
        if ($this-&gt;params['pass']) {
            $viewPath = DS . implode(DS, $this-&gt;params['pass']) . $viewPath;
        }

        if (file_exists(VIEWS.'pages'.$viewPath)) {
            $this-&gt;render(null, null, VIEWS.'pages'.$viewPath);
        } else {
            $this-&gt;cakeError('error404');
        }
    }
}
</pre>
<p>To get the aforementioned URL scheme we have to define a &#8220;catch all&#8221; route in app/config/routes.php:</p>
<pre>
Router::connect('*', array('controller' =&gt; 'pages', 'action' =&gt; 'display'));
</pre>
<p>This route has to be the latest route in the routes file. And that&#8217;s also the disadvantage of this approach: because of the &#8220;catch all&#8221; route you have to define routes for all controllers&#8230;</p>
<p>Anyway, I hope this approach is useful for some of you :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/06/18/an-alternative-approach-for-static-pages/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>A missing concept: model &#8220;components&#8221;</title>
		<link>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/</link>
		<comments>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/#comments</comments>
		<pubDate>Thu, 15 May 2008 08:43:55 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=603</guid>
		<description><![CDATA[The fatter your models become, the more obvious it is (at least for me) that something is missing. Let&#8217;s say we have a bunch of models. Two of those models use internally the same functionality. To avoid code duplication, you want to share this functionality between the two models. But how could you accomplish that? [...]]]></description>
			<content:encoded><![CDATA[<p>The fatter your models become, the more obvious it is (at least for me) that something is missing. Let&#8217;s say we have a bunch of models. Two of those models use internally the same functionality. To avoid code duplication, you want to share this functionality between the two models. But how could you accomplish that? </p>
<p>One idea is to move the functionality to the AppModel. That works, but it is a dirty solution. The AppModel should contain generic functionality relevant for all models, and not functionality specific to only two models. </p>
<p>Another idea is to move the functionality into a class in the vendors folder and to load it with App::import(). That works fine, but if you compare this solution with elements and helpers for reusing view functionality, and with components for reusing controller functionality, it is a bit strange there is no &#8220;native&#8221; solution for models (sure, there are behaviors, but they are not designed for the kind of code reuse I described above).</p>
<p>Hence I think it would be useful to have model &#8220;components&#8221;, which could be realized in the same way as controller components are realized. For example:</p>
<pre>
class Example extends AppModel {
    public $components = array('X');

    public function doSomething() {
        ...
        $this-&gt;X-&gt;doSomethingElse(); // using model component
        ...
    }
}
</pre>
<p>In the longer term it would even make sense to have a unified &#8220;components&#8221; concept to replace the current concepts of components and helpers. But well, we will see what the future brings ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/05/15/a-missing-concept-model-components/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Thinking about the model II</title>
		<link>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/</link>
		<comments>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 17:11:02 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=596</guid>
		<description><![CDATA[A while ago I wrote an article Thinking about the model in which I shared some ideas about how CakePHP&#8217;s Model class could be improved. In this article I want to share another idea for the Model class. If you look at the Model class you will see that it represents two different &#8220;things&#8221;: on [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote an article <a href="http://cakebaker.42dh.com/2008/01/16/thinking-about-the-model/">Thinking about the model</a> in which I shared some ideas about how CakePHP&#8217;s Model class could be improved. In this article I want to share another idea for the Model class. </p>
<p>If you look at the Model class you will see that it represents two different &#8220;things&#8221;: on the one hand it represents a single record, and on the other hand it represents a table (or to be more generic: a container of records). That&#8217;s not that clean from an object-oriented point of view, and hence I think it would make sense to split the Model class into two parts, e.g. Record and Container. All properties and methods related to a single record would be in the Record class, and all table-oriented functionality in the Container class (see also the <a href="http://www.djangobook.com/en/1.0/appendixB/">&#8220;Managers&#8221; section</a> in the Django book, which describes a very similar concept). In practice it could look like:</p>
<pre>
$post = $this-&gt;Posts-&gt;findById(1); // Posts is a Container which returns a Post object (a Record class)
$post-&gt;delete(); // delete the post with id 1
</pre>
<p>Maybe this is something for CakePHP 2.0?</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/04/22/thinking-about-the-model-ii/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Thinking about the model</title>
		<link>http://cakebaker.42dh.com/2008/01/16/thinking-about-the-model/</link>
		<comments>http://cakebaker.42dh.com/2008/01/16/thinking-about-the-model/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 10:10:19 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/01/16/thinking-about-the-model/</guid>
		<description><![CDATA[Due to a cold I had some time to think in the last few days (besides drinking tea, sleeping a lot, and watching videos). One thing I thought about was the Model class and how it could be improved. If you look carefully at the API of the Model class, you will see that the [...]]]></description>
			<content:encoded><![CDATA[<p>Due to a cold I had some time to think in the last few days (besides drinking tea, sleeping a lot, and watching videos). One thing I thought about was the Model class and how it could be improved. </p>
<p>If you look carefully at the <a href="http://api.cakephp.org/1.2/class_model.html">API of the Model class</a>, you will see that the current implementation assumes quite a bit about your models which doesn&#8217;t have to be true. So it assumes that you want to be able to find, update, save, and delete records through the model. Even though that&#8217;s often the case, it&#8217;s not always true. For example, you may want to have a read-only model. It&#8217;s something you cannot implement elegantly with CakePHP, as your model will always inherit methods like deleteAll(), save(), etc., and so those methods are part of the API of your model&#8230;</p>
<p>There are at least two possible ways to improve this. </p>
<p>The first approach is to make all such methods in Model protected. That means you could use those methods only from within your models. If you want to provide a delete-method, you would have to explicitly define such a method in your model and to delegate to the appropriate method from Model. The disadvantage of this approach is that it probably breaks a lot of code&#8230;</p>
<p>The second idea is to split the aforementioned functionality of the model into different behaviors. When writing your own model you can then choose which behaviors your model should have. For example, your model would use a &#8220;deletable&#8221; behavior if it should allow to delete records.</p>
<p>I am sure there are better ways than those I described here. They are simply thought as an inspiration to think about improving the model and to make it less fat ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/01/16/thinking-about-the-model/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Simplifying the App(Controller/Model/Helper) concept</title>
		<link>http://cakebaker.42dh.com/2007/11/16/simplifying-the-appcontrollermodelhelper-concept/</link>
		<comments>http://cakebaker.42dh.com/2007/11/16/simplifying-the-appcontrollermodelhelper-concept/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 14:31:09 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/11/16/simplifying-the-appcontrollermodelhelper-concept/</guid>
		<description><![CDATA[Yesterday, the classes AppController, AppModel, and AppHelper were moved from the &#8220;cake&#8221; folder to the &#8220;cake/libs/controller&#8221;, &#8220;cake/libs/model&#8221;, respectively &#8220;cake/libs/view/helpers&#8221; folders (see changesets 5997 and 5998). Due to this move, my code suddenly broke as the AppHelper class wasn&#8217;t found because CakePHP still looked for it in the original folder. Creating an empty AppHelper class in [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, the classes AppController, AppModel, and AppHelper were moved from the &#8220;cake&#8221; folder to the &#8220;cake/libs/controller&#8221;, &#8220;cake/libs/model&#8221;, respectively &#8220;cake/libs/view/helpers&#8221; folders (see changesets <a href="https://trac.cakephp.org/changeset/5997">5997</a> and <a href="https://trac.cakephp.org/changeset/5998">5998</a>). Due to this move, my code suddenly broke as the AppHelper class wasn&#8217;t found because CakePHP still looked for it in the original folder. Creating an empty AppHelper class in my &#8220;app&#8221; folder solved the problem.</p>
<p>Anyway, what I realized by this incident is that the implementation of this entire concept is unnecessary &#8220;complex&#8221;. I must have been blind I didn&#8217;t saw this earlier ;-)</p>
<p>If you, for example, want to add some functionality to the AppController, you have either to copy the file app_controller.php from the &#8220;cake&#8221; (resp. new &#8220;cake/libs/controller&#8221;) folder to the &#8220;app&#8221; folder, or you have to create the file yourself in the &#8220;app&#8221; folder. That&#8217;s because you shouldn&#8217;t edit any files in the &#8220;cake&#8221; folder and its subfolders. This often leads to confusion: if you tell a newbie he should add something to &#8220;app/app_controller.php&#8221;, then the file is not there&#8230;</p>
<p>But it also makes the life of the (framework) developers a bit harder, as you have to check whether the files exist in the &#8220;app&#8221; folder, and depending on this check you then load the files either from the &#8220;app&#8221; or &#8220;cake&#8221; folder. </p>
<p>Sure, the aforementioned topics are no big deal, but on the other hand there are no benefits in doing it in the way it is currently done (or at least I don&#8217;t see any benefits). </p>
<p>A simpler solution would be to add AppController, AppModel, and AppHelper to the &#8220;app&#8221; folder by default (which is already done by the bake script when you bake a project). So those classes in the &#8220;cake&#8221; folder would be redundant and could be removed (and you could forget what I wrote above). <a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a>, keep it simple and stupid!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/11/16/simplifying-the-appcontrollermodelhelper-concept/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Do we really need HTML and CSS on the web?</title>
		<link>http://cakebaker.42dh.com/2006/10/07/do-we-really-need-html-and-css-on-the-web/</link>
		<comments>http://cakebaker.42dh.com/2006/10/07/do-we-really-need-html-and-css-on-the-web/#comments</comments>
		<pubDate>Sat, 07 Oct 2006 15:42:37 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/10/07/do-we-really-need-html-and-css-on-the-web/</guid>
		<description><![CDATA[A provocative question, I know. But I like to try to get to the bottom of something from time to time, and to give my fancy full scope ;-) Let&#8217;s start with another question: what do we do on the web? We read news, we compare prices, we buy products, we learn, we look at [...]]]></description>
			<content:encoded><![CDATA[<p>A provocative question, I know. But I like to try to get to the bottom of something from time to time, and to give my fancy full scope ;-)</p>
<p>Let&#8217;s start with another question: what do we do on the web? We read news, we compare prices, we buy products, we learn, we look at pictures, etc., in short we are interested in content. Content is king. So the design of the sites is not that important. Of course it is more pleasant if a site has a nice design, but that&#8217;s not the reason a site is visited. It&#8217;s because of its content. </p>
<p>So we can say the web is about content. Ok. But HTML and CSS are primary for design purposes. Hm. Could it be that HTML and CSS are a wrong solution for websites? It is possible. There are some indicators for that:</p>
<ul>
<li>HTML and CSS are (too) complex, which makes it difficult for non-technical people to create websites</li>
<li>too much time must be invested to make a website look correct in the different browsers</li>
<li>extra work is needed if a website should be accessible for disabled people</li>
</ul>
<p>What could be an alternative? I think an alternative approach should be similar to plain-text email, with no possibilities to format anything. So it would be really easy to create content, just open an editor and start writing (like writing an email). And you would no longer have to worry about the different browsers, because the content is shown in the way it was entered, with just one font and one font size&#8230;</p>
<p>What do you think about this topic?</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/10/07/do-we-really-need-html-and-css-on-the-web/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
