<?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: Lessons learned from loadController(null)</title>
	<atom:link href="http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:41:30 +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/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-11014</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 06 Sep 2007 08:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-11014</guid>
		<description>@m3ntor: Thanks for your comment, I agree fully with you ;-)</description>
		<content:encoded><![CDATA[<p>@m3ntor: Thanks for your comment, I agree fully with you ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: m3nt0r</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10978</link>
		<dc:creator>m3nt0r</dc:creator>
		<pubDate>Mon, 03 Sep 2007 22:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10978</guid>
		<description>Even its a little late: I agree with Daniel. I would never expect a function to do something if i pass &quot;null&quot;.

In all coding guidelines i&#039;ve read, people suggested to be verbose in naming so that the code is understandable without knowing the entire source.

* hasSomething
* doSomething
* isSomething 

In the case described we &quot;load&quot; a &quot;controller&quot;. So if i would read a source that has the following in it, i would expect to happen or fail.

&lt;code&gt;if (loadController($userinput)) {
    // success
} else {
   // notice user
}&lt;/code&gt;

Now let&#039;s assume $userinput is not set, empty - it&#039;s null. In that case the current loadController would return true, even though the userinput is not available and nothing happens as expected. The user did something wrong. He did not enter a controller name, but the function keeps returning &quot;true&quot;. That&#039;s bad...

I don&#039;t know a way how to make this clearer. 

If i read API Docs and i see a bool-function with a descriptive name like &quot;createFile&quot; and just a single argument i expect it to fail if the value is left empty. 

When i write functions like that i begin with an if-sentence before i do anything else and i encourage everyone to do so too. 

&lt;code&gt;if($name) 
   require app_controller, 
   require $name 
(else) 
   error, return false&lt;/code&gt;

Even &quot;null&quot; is there for a reason. :-)

JM2C</description>
		<content:encoded><![CDATA[<p>Even its a little late: I agree with Daniel. I would never expect a function to do something if i pass &#8220;null&#8221;.</p>
<p>In all coding guidelines i&#8217;ve read, people suggested to be verbose in naming so that the code is understandable without knowing the entire source.</p>
<p>* hasSomething<br />
* doSomething<br />
* isSomething </p>
<p>In the case described we &#8220;load&#8221; a &#8220;controller&#8221;. So if i would read a source that has the following in it, i would expect to happen or fail.</p>
<pre><code>if (loadController($userinput)) {
    // success
} else {
   // notice user
}</code></pre>
<p>Now let&#8217;s assume $userinput is not set, empty &#8211; it&#8217;s null. In that case the current loadController would return true, even though the userinput is not available and nothing happens as expected. The user did something wrong. He did not enter a controller name, but the function keeps returning &#8220;true&#8221;. That&#8217;s bad&#8230;</p>
<p>I don&#8217;t know a way how to make this clearer. </p>
<p>If i read API Docs and i see a bool-function with a descriptive name like &#8220;createFile&#8221; and just a single argument i expect it to fail if the value is left empty. </p>
<p>When i write functions like that i begin with an if-sentence before i do anything else and i encourage everyone to do so too. </p>
<pre><code>if($name) 
   require app_controller, 
   require $name 
(else) 
   error, return false</code></pre>
<p>Even &#8220;null&#8221; is there for a reason. :-)</p>
<p>JM2C</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10808</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 28 Aug 2007 12:10:29 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10808</guid>
		<description>@Fallenjehova: Thanks. I&#039;m sorry, but I don&#039;t have the IRC logs. 

Well, the semantics of the function signature loadController($name) is that it loads the controller with the specified name. If you now pass null as parameter, you violate this semantic as null is not a valid controller name and hence the function should throw an error (and not load the AppController).

I hope it is now more clear :)</description>
		<content:encoded><![CDATA[<p>@Fallenjehova: Thanks. I&#8217;m sorry, but I don&#8217;t have the IRC logs. </p>
<p>Well, the semantics of the function signature loadController($name) is that it loads the controller with the specified name. If you now pass null as parameter, you violate this semantic as null is not a valid controller name and hence the function should throw an error (and not load the AppController).</p>
<p>I hope it is now more clear :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fallenjehova</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10796</link>
		<dc:creator>Fallenjehova</dc:creator>
		<pubDate>Mon, 27 Aug 2007 15:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10796</guid>
		<description>Nice post Daniel,

I&#039;m veeeeery curious. As the irc log is unavalaible right now, do you or nate have the irc logs about this topic? (semantics of this function).</description>
		<content:encoded><![CDATA[<p>Nice post Daniel,</p>
<p>I&#8217;m veeeeery curious. As the irc log is unavalaible right now, do you or nate have the irc logs about this topic? (semantics of this function).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10789</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 27 Aug 2007 08:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10789</guid>
		<description>@nate, Tarique: Thanks for your comments!

@nate: For me the issue is not the incomplete doc block but the semantic of the function. But as discussed in IRC we disagree in this point.

@Tarique: I fully agree with you.</description>
		<content:encoded><![CDATA[<p>@nate, Tarique: Thanks for your comments!</p>
<p>@nate: For me the issue is not the incomplete doc block but the semantic of the function. But as discussed in IRC we disagree in this point.</p>
<p>@Tarique: I fully agree with you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarique Sani</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10769</link>
		<dc:creator>Tarique Sani</dc:creator>
		<pubDate>Fri, 24 Aug 2007 09:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10769</guid>
		<description>Good point - Comment the &quot;why&quot; of code rather than the much obvious &quot;how&quot; of code.  

Comments like //Increment $counter by 1 are very obvious and thus the comment is redundant but  &quot;why&quot; the $counter is being incremented may not be obvious and needs to be commented</description>
		<content:encoded><![CDATA[<p>Good point &#8211; Comment the &#8220;why&#8221; of code rather than the much obvious &#8220;how&#8221; of code.  </p>
<p>Comments like //Increment $counter by 1 are very obvious and thus the comment is redundant but  &#8220;why&#8221; the $counter is being incremented may not be obvious and needs to be commented</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nate</title>
		<link>http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/comment-page-1/#comment-10765</link>
		<dc:creator>nate</dc:creator>
		<pubDate>Thu, 23 Aug 2007 14:15:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/08/23/lessons-learned-from-loadcontrollernull/#comment-10765</guid>
		<description>You&#039;re more than welcome to update the docblock. ;-)

That&#039;s definitely one area where we could use some help.</description>
		<content:encoded><![CDATA[<p>You&#8217;re more than welcome to update the docblock. ;-)</p>
<p>That&#8217;s definitely one area where we could use some help.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
