<?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: Don&#8217;t change the meaning of parameters</title>
	<atom:link href="http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/</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/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123333</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 18 Mar 2009 16:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123333</guid>
		<description>@ADmad: Yes, that&#039;s true. In the end it is probably a matter of preference which approach you use.</description>
		<content:encoded><![CDATA[<p>@ADmad: Yes, that&#8217;s true. In the end it is probably a matter of preference which approach you use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ADmad</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123282</link>
		<dc:creator>ADmad</dc:creator>
		<pubDate>Tue, 17 Mar 2009 19:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123282</guid>
		<description>@cakebaker  I am not mixing anymore than core already does. You can pass an options array as second param. I am just adding one more key to it.</description>
		<content:encoded><![CDATA[<p>@cakebaker  I am not mixing anymore than core already does. You can pass an options array as second param. I am just adding one more key to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123274</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 17 Mar 2009 16:46:38 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123274</guid>
		<description>@all: Thanks for your comments!

@Jonah: I think the problem of such an approach is that the parameters $whiteList and $blackList are mutually exclusive. You use either a whiteList or a blackList strategy, but not both. And having such a method signature doesn&#039;t communicate this fact...

@teknoid: Yes, as long as it is not supported by the core, you have to find a workaround. 

@Brandon: Yes, I fully agree with you.

@poLK: Yes, writing a behavior is a possible workaround. 

@ADmad: Yes, that&#039;s a possible workaround, however your solution still mixes responsibilities.

@Abba: Not me ;-)</description>
		<content:encoded><![CDATA[<p>@all: Thanks for your comments!</p>
<p>@Jonah: I think the problem of such an approach is that the parameters $whiteList and $blackList are mutually exclusive. You use either a whiteList or a blackList strategy, but not both. And having such a method signature doesn&#8217;t communicate this fact&#8230;</p>
<p>@teknoid: Yes, as long as it is not supported by the core, you have to find a workaround. </p>
<p>@Brandon: Yes, I fully agree with you.</p>
<p>@poLK: Yes, writing a behavior is a possible workaround. </p>
<p>@ADmad: Yes, that&#8217;s a possible workaround, however your solution still mixes responsibilities.</p>
<p>@Abba: Not me ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abba Bryant</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123264</link>
		<dc:creator>Abba Bryant</dc:creator>
		<pubDate>Tue, 17 Mar 2009 15:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123264</guid>
		<description>Who is going to be first to write a full featured blacklistable behavior?</description>
		<content:encoded><![CDATA[<p>Who is going to be first to write a full featured blacklistable behavior?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ADmad</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123199</link>
		<dc:creator>ADmad</dc:creator>
		<pubDate>Mon, 16 Mar 2009 14:47:25 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123199</guid>
		<description>&lt;code&gt;
//$this-&gt;ModelName-&gt;save($data, array(&#039;blackList&#039; =&gt; array(&#039;fieldA&#039;, &#039;fieldB&#039;)))

function save($data = null, $validate = true, $fieldList = array()) {
	if (is_array($validate) &amp;&amp; isset($validate[&#039;blackList&#039;])) {
		if(!empty($this-&gt;whitelist)) {
			$validate[&#039;fieldList&#039;] = array_diff($this-&gt;whitelist, $validate[&#039;blackList&#039;]);
		} else {
			$validate[&#039;fieldList&#039;] = array_diff(array_keys($this-&gt;schema()), $validate[&#039;blackList&#039;]);
		}
	}
	return parent::save($data, $validate, $fieldList);
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<pre><code>//$this-&gt;ModelName-&gt;save($data, array('blackList' =&gt; array('fieldA', 'fieldB')))

function save($data = null, $validate = true, $fieldList = array()) {
	if (is_array($validate) &amp;&amp; isset($validate['blackList'])) {
		if(!empty($this-&gt;whitelist)) {
			$validate['fieldList'] = array_diff($this-&gt;whitelist, $validate['blackList']);
		} else {
			$validate['fieldList'] = array_diff(array_keys($this-&gt;schema()), $validate['blackList']);
		}
	}
	return parent::save($data, $validate, $fieldList);
}</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: poLK</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123175</link>
		<dc:creator>poLK</dc:creator>
		<pubDate>Mon, 16 Mar 2009 05:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123175</guid>
		<description>I forgot to point out that Model::$whitelist is public property.</description>
		<content:encoded><![CDATA[<p>I forgot to point out that Model::$whitelist is public property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: poLK</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123174</link>
		<dc:creator>poLK</dc:creator>
		<pubDate>Mon, 16 Mar 2009 05:52:38 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123174</guid>
		<description>&lt;code&gt;
//$this-&gt;ModelName-&gt;save($data, array(&#039;blacklist&#039; =&gt; array(&#039;fieldA&#039;, &#039;fieldB&#039;)))

class BlacklistBehavior extends ModelBehavior {
	public function beforeSave(&amp;$Model, $options = array()) {
		debug($options);
	}
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<pre><code>//$this-&gt;ModelName-&gt;save($data, array('blacklist' =&gt; array('fieldA', 'fieldB')))

class BlacklistBehavior extends ModelBehavior {
	public function beforeSave(&amp;$Model, $options = array()) {
		debug($options);
	}
}</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon P</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123169</link>
		<dc:creator>Brandon P</dc:creator>
		<pubDate>Mon, 16 Mar 2009 04:40:13 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123169</guid>
		<description>Sorry, but issues like this perplex me.  Why do people want to change the functionality of core components?  There is no way that a framework can cover every use-case scenario out there.

If a framework doesn&#039;t provide built-in functionality for what you are trying to do, take the time and add it to AppModel or a utility class (making it reusable) that Daniel suggested rather than writing about how core components should be changed to meet your obscure needs.

Frameworks are general, made up of classes to help you solve common/everyday/redundant tasks.  Don&#039;t get surprised or frustrated when something doesn&#039;t work out of the box.  And please don&#039;t waste your time trying to get a framework to work for you.  Let it do what it&#039;s designed to do.  Any specific tasks you want, create your own functionality decoupled from the framework as much as possible so its highly reusable.</description>
		<content:encoded><![CDATA[<p>Sorry, but issues like this perplex me.  Why do people want to change the functionality of core components?  There is no way that a framework can cover every use-case scenario out there.</p>
<p>If a framework doesn&#8217;t provide built-in functionality for what you are trying to do, take the time and add it to AppModel or a utility class (making it reusable) that Daniel suggested rather than writing about how core components should be changed to meet your obscure needs.</p>
<p>Frameworks are general, made up of classes to help you solve common/everyday/redundant tasks.  Don&#8217;t get surprised or frustrated when something doesn&#8217;t work out of the box.  And please don&#8217;t waste your time trying to get a framework to work for you.  Let it do what it&#8217;s designed to do.  Any specific tasks you want, create your own functionality decoupled from the framework as much as possible so its highly reusable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teknoid</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123145</link>
		<dc:creator>teknoid</dc:creator>
		<pubDate>Sun, 15 Mar 2009 21:30:09 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123145</guid>
		<description>I absolutely agree that from a programmatic point of view one should not hack away at the designated parameter to make it behave as  something else.

However, this functionality is desired in many cases (still IMO), and ultimately what Jonah proposed is the best approach. Yet, until it is supported by the core we are stuck with a some little hacks one way or another.</description>
		<content:encoded><![CDATA[<p>I absolutely agree that from a programmatic point of view one should not hack away at the designated parameter to make it behave as  something else.</p>
<p>However, this functionality is desired in many cases (still IMO), and ultimately what Jonah proposed is the best approach. Yet, until it is supported by the core we are stuck with a some little hacks one way or another.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonah</title>
		<link>http://cakebaker.42dh.com/2009/03/15/dont-change-the-meaning-of-parameters/comment-page-1/#comment-123139</link>
		<dc:creator>Jonah</dc:creator>
		<pubDate>Sun, 15 Mar 2009 21:08:39 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1143#comment-123139</guid>
		<description>I don&#039;t like any of these solutions.

Why not this signature:

save($data = null, $validate = true, $whiteList = false, $blackList = false)

You could use one, the other, or both even</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like any of these solutions.</p>
<p>Why not this signature:</p>
<p>save($data = null, $validate = true, $whiteList = false, $blackList = false)</p>
<p>You could use one, the other, or both even</p>
]]></content:encoded>
	</item>
</channel>
</rss>
