<?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: Factory Method pattern; ATLPHP tonight!</title>
	<atom:link href="http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/</link>
	<description></description>
	<lastBuildDate>Sun, 19 Jun 2011 01:18:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
	<item>
		<title>By: Brian DeShong</title>
		<link>http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/comment-page-1/#comment-94</link>
		<dc:creator>Brian DeShong</dc:creator>
		<pubDate>Fri, 09 Jan 2009 14:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=169#comment-94</guid>
		<description>@Saad Tazi: I assume you&#039;re referring to the example with &quot;foo,&quot; &quot;bar,&quot; &quot;hockey,&quot; and &quot;baseball&quot; classes.  That example is a pretty simple one, but you&#039;re right, I suppose you could use a class_exists() call there.

But, on the flip side, in my later examples, I&#039;m mapping the concept of &quot;fast car&quot; to Car_Ferrari, and &quot;slow car&quot; to Car_Yugo, so that doesn&#039;t map as nicely.

But sure, if you had a simple string-to-class name mapping, you could use class_exists() with it.

I&#039;m not sure that I&#039;d recommend that for the reasons that then your developer would be able to effectively instantiate an object of ANY type from that factory, which misses the point.  The idea is that any object returned should adhere to a common interface.

If you had classes &quot;car&quot; and &quot;hot air balloon,&quot; those aren&#039;t going to have the same interface, so you wouldn&#039;t want to be able to create both of those objects from the same factory.</description>
		<content:encoded><![CDATA[<p>@Saad Tazi: I assume you&#8217;re referring to the example with &#8220;foo,&#8221; &#8220;bar,&#8221; &#8220;hockey,&#8221; and &#8220;baseball&#8221; classes.  That example is a pretty simple one, but you&#8217;re right, I suppose you could use a class_exists() call there.</p>
<p>But, on the flip side, in my later examples, I&#8217;m mapping the concept of &#8220;fast car&#8221; to Car_Ferrari, and &#8220;slow car&#8221; to Car_Yugo, so that doesn&#8217;t map as nicely.</p>
<p>But sure, if you had a simple string-to-class name mapping, you could use class_exists() with it.</p>
<p>I&#8217;m not sure that I&#8217;d recommend that for the reasons that then your developer would be able to effectively instantiate an object of ANY type from that factory, which misses the point.  The idea is that any object returned should adhere to a common interface.</p>
<p>If you had classes &#8220;car&#8221; and &#8220;hot air balloon,&#8221; those aren&#8217;t going to have the same interface, so you wouldn&#8217;t want to be able to create both of those objects from the same factory.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian DeShong</title>
		<link>http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/comment-page-1/#comment-93</link>
		<dc:creator>Brian DeShong</dc:creator>
		<pubDate>Fri, 09 Jan 2009 14:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=169#comment-93</guid>
		<description>@beberlei Sure, I suppose you could make them non-static methods.  Personally, I&#039;ve never seen it done that way, and in my experience, I&#039;ve never seen that approach documented in one of the &quot;classic&quot; books floating around.

But sure, I suppose you could take that approach.

In general, if a method is not dependent on a data member in an object, then that&#039;s a sign that it might be able to be static.  Hence, why factory methods are generally static.</description>
		<content:encoded><![CDATA[<p>@beberlei Sure, I suppose you could make them non-static methods.  Personally, I&#8217;ve never seen it done that way, and in my experience, I&#8217;ve never seen that approach documented in one of the &#8220;classic&#8221; books floating around.</p>
<p>But sure, I suppose you could take that approach.</p>
<p>In general, if a method is not dependent on a data member in an object, then that&#8217;s a sign that it might be able to be static.  Hence, why factory methods are generally static.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saad Tazi</title>
		<link>http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/comment-page-1/#comment-92</link>
		<dc:creator>Saad Tazi</dc:creator>
		<pubDate>Fri, 09 Jan 2009 14:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=169#comment-92</guid>
		<description>Hi,
Is there any reason you don&#039;t use the class_exists method in your factory instead of the case statement? Performance?

http://ca3.php.net/manual/en/function.class-exists.php

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Is there any reason you don&#8217;t use the class_exists method in your factory instead of the case statement? Performance?</p>
<p><a href="http://ca3.php.net/manual/en/function.class-exists.php" rel="nofollow">http://ca3.php.net/manual/en/function.class-exists.php</a></p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beberlei</title>
		<link>http://www.deshong.net/2009/01/factory-method-pattern-atlphp-tonight/comment-page-1/#comment-91</link>
		<dc:creator>beberlei</dc:creator>
		<pubDate>Fri, 09 Jan 2009 07:56:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=169#comment-91</guid>
		<description>Nice slides! But one point confuses me:

&quot;Your factory: It&#039;s always a static method&quot;.

Isn&#039;t it even better for it to be an object with methods rather than static access? This way you could switch it far more easy for testing, since you cannot mock static functions.

The Dynamic factory could be mocked to return a mock object when used for testing.</description>
		<content:encoded><![CDATA[<p>Nice slides! But one point confuses me:</p>
<p>&#8220;Your factory: It&#8217;s always a static method&#8221;.</p>
<p>Isn&#8217;t it even better for it to be an object with methods rather than static access? This way you could switch it far more easy for testing, since you cannot mock static functions.</p>
<p>The Dynamic factory could be mocked to return a mock object when used for testing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

