<?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; pattern</title>
	<atom:link href="http://cakebaker.42dh.com/tags/pattern/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>The &#8220;Multitype Parameter&#8221; Pattern</title>
		<link>http://cakebaker.42dh.com/2007/06/18/the-multitype-parameter-pattern/</link>
		<comments>http://cakebaker.42dh.com/2007/06/18/the-multitype-parameter-pattern/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 09:18:05 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[pattern]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/06/18/the-multitype-parameter-pattern/</guid>
		<description><![CDATA[One of the patterns you find throughout CakePHP is what I call the &#8220;Multitype Parameter&#8221; pattern (maybe there exists an &#8220;official&#8221; name for it, I don&#8217;t know). It allows you to either pass a string or an array as a parameter to a function. An example: $this-&#62;redirect('/users/add'); or $this-&#62;redirect(array('controller' =&#62; 'Users', 'action' =&#62; 'add')); As [...]]]></description>
			<content:encoded><![CDATA[<p>One of the patterns you find throughout CakePHP is what I call the &#8220;Multitype Parameter&#8221; pattern (maybe there exists an &#8220;official&#8221; name for it, I don&#8217;t know). It allows you to either pass a string or an array as a parameter to a function. An example:</p>
<pre>
$this-&gt;redirect('/users/add');

or

$this-&gt;redirect(array('controller' =&gt; 'Users', 'action' =&gt; 'add'));
</pre>
<p>As usual in software engineering, using such a pattern comes with trade-offs. On the one hand you get a flexible interface you can extend very easily by adding new keywords, and which is handy for the user as in the usual case he can simply pass a string whereas in other cases he can pass an array. On the other hand you have to write more code and it becomes more difficult to override a method using this pattern.</p>
<p>I don&#8217;t use that pattern often in my own stuff, but maybe it will be helpful to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/06/18/the-multitype-parameter-pattern/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

