<?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: The Chain-of-Command Pattern: OOP Techniques in PHP</title>
	<atom:link href="http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html</link>
	<description></description>
	<lastBuildDate>Mon, 05 Dec 2011 04:29:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Will Fitch</title>
		<link>http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html#comment-690</link>
		<dc:creator>Will Fitch</dc:creator>
		<pubDate>Tue, 09 Feb 2010 21:27:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpfever.com/?p=160#comment-690</guid>
		<description>Thanks, Clayton.

You&#039;re correct on the typo.

The separation is the execution and &quot;genericism&quot; (a little G W Bush for ya).

Yes, if the $_commands array is empty, we don&#039;t want to attempt to execute the foreach loop.

Clayton, would you be interested in joining the alpha dev team?  If so, shoot me an email.</description>
		<content:encoded><![CDATA[<p>Thanks, Clayton.</p>
<p>You&#8217;re correct on the typo.</p>
<p>The separation is the execution and &#8220;genericism&#8221; (a little G W Bush for ya).</p>
<p>Yes, if the $_commands array is empty, we don&#8217;t want to attempt to execute the foreach loop.</p>
<p>Clayton, would you be interested in joining the alpha dev team?  If so, shoot me an email.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clayton</title>
		<link>http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html#comment-689</link>
		<dc:creator>Clayton</dc:creator>
		<pubDate>Tue, 09 Feb 2010 15:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpfever.com/?p=160#comment-689</guid>
		<description>Just so we&#039;re clear the only separation between this CoC pattern and the Observer pattern, is that the CoC pattern exits the loop the second an object handles the event?

Also in your example there&#039;s &#039;if (count($commands) &gt; 0)&#039; I assume this is a typo and should be &#039;if (count($this-&gt;_commands) &gt; 0)&#039;. In which case, is the if statement required as the foreach wont execute if the array is empty.

Btw I&#039;m looking forward to your Fever Framework.</description>
		<content:encoded><![CDATA[<p>Just so we&#8217;re clear the only separation between this CoC pattern and the Observer pattern, is that the CoC pattern exits the loop the second an object handles the event?</p>
<p>Also in your example there&#8217;s &#8216;if (count($commands) &gt; 0)&#8217; I assume this is a typo and should be &#8216;if (count($this-&gt;_commands) &gt; 0)&#8217;. In which case, is the if statement required as the foreach wont execute if the array is empty.</p>
<p>Btw I&#8217;m looking forward to your Fever Framework.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will Fitch</title>
		<link>http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html#comment-688</link>
		<dc:creator>Will Fitch</dc:creator>
		<pubDate>Tue, 09 Feb 2010 08:05:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpfever.com/?p=160#comment-688</guid>
		<description>Both are a subscriber/publisher type of setup. The main difference is purpose. The CoC could be described as a very generic version of the Observer.  The CoC goal is to chain events together and execute until an object handles it.

The Observer, on the other hand, has specific attributes.  You may have an observer that is specific to database events, service events, etc.  This can also get confused with the Decorator pattern.

The Decorator is actually closer to CoC than Observer.  Rather than executing until an object handles something, the Decorator iterates over all objects to format functionality.  Logging is a good example.

$log = new Logger();
$log-&gt;addLogger(new FileLogger($file_name));
$log-&gt;addLogger(new DBLogger($db_conn));
..
..
..

$log-&gt;log(&#039;error&#039;,&#039;This is an error!&#039;);

The above logs a single request to multiple sources via a single interface.</description>
		<content:encoded><![CDATA[<p>Both are a subscriber/publisher type of setup. The main difference is purpose. The CoC could be described as a very generic version of the Observer.  The CoC goal is to chain events together and execute until an object handles it.</p>
<p>The Observer, on the other hand, has specific attributes.  You may have an observer that is specific to database events, service events, etc.  This can also get confused with the Decorator pattern.</p>
<p>The Decorator is actually closer to CoC than Observer.  Rather than executing until an object handles something, the Decorator iterates over all objects to format functionality.  Logging is a good example.</p>
<p>$log = new Logger();<br />
$log->addLogger(new FileLogger($file_name));<br />
$log->addLogger(new DBLogger($db_conn));<br />
..<br />
..<br />
..</p>
<p>$log->log(&#8216;error&#8217;,'This is an error!&#8217;);</p>
<p>The above logs a single request to multiple sources via a single interface.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clayton</title>
		<link>http://www.willfitch.com/the-chain-of-command-pattern-oop-techniques-in-php.html#comment-687</link>
		<dc:creator>Clayton</dc:creator>
		<pubDate>Tue, 09 Feb 2010 02:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpfever.com/?p=160#comment-687</guid>
		<description>Couldn&#039;t this CoC pattern be described as the Observer pattern?

Looking at it, it would look very similar albeit with a different name.

The basis of both is you have subject and a subscriber. A subject acts as a publisher and a subscriber receives updates from that publisher.

$observer = new Observer();

// You could optionally specify the nature of the subscription, in the second argument
$observer-&gt;subscribe(new Mailer());

// This essentially runs the command
$observer-&gt;publish(&#039;mailer&#039;, array(&#039;address&#039; =&gt; &#039;you@and.me&#039;));


Another example often seen involves the use of events and triggers.
$observer-&gt;addEvent(new Log());
$observer-&gt;trigger(&#039;error&#039;, array());</description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t this CoC pattern be described as the Observer pattern?</p>
<p>Looking at it, it would look very similar albeit with a different name.</p>
<p>The basis of both is you have subject and a subscriber. A subject acts as a publisher and a subscriber receives updates from that publisher.</p>
<p>$observer = new Observer();</p>
<p>// You could optionally specify the nature of the subscription, in the second argument<br />
$observer-&gt;subscribe(new Mailer());</p>
<p>// This essentially runs the command<br />
$observer-&gt;publish(&#8216;mailer&#8217;, array(&#8216;address&#8217; =&gt; &#8216;you@and.me&#8217;));</p>
<p>Another example often seen involves the use of events and triggers.<br />
$observer-&gt;addEvent(new Log());<br />
$observer-&gt;trigger(&#8216;error&#8217;, array());</p>
]]></content:encoded>
	</item>
</channel>
</rss>

