<?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: Collaborator vs. the Factory</title>
	<atom:link href="http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/feed/" rel="self" type="application/rss+xml" />
	<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/</link>
	<description>Testability Explorer</description>
	<lastBuildDate>Fri, 30 Jul 2010 03:59:03 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: EIP Special Report: DDD Is All Around &#171; I Built His Cage</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-1156</link>
		<dc:creator>EIP Special Report: DDD Is All Around &#171; I Built His Cage</dc:creator>
		<pubDate>Thu, 04 Jun 2009 01:45:32 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-1156</guid>
		<description>[...] a domain layer, and a UI layer. Components are injected everywhere (homemade DI). Factories are the only classes that instantiate classes. And the result is some of the most beautiful code I&#8217;ve ever written, and I doubt it took any [...]</description>
		<content:encoded><![CDATA[<p>[...] a domain layer, and a UI layer. Components are injected everywhere (homemade DI). Factories are the only classes that instantiate classes. And the result is some of the most beautiful code I&#8217;ve ever written, and I doubt it took any [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-996</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Sun, 10 May 2009 04:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-996</guid>
		<description>@Zen,

Thanks for posting, but I don&#039;t think I understand your question or what you think are the differences between your two example or how it solves the if in factory problem. Could you explain your view in more detail.</description>
		<content:encoded><![CDATA[<p>@Zen,</p>
<p>Thanks for posting, but I don&#8217;t think I understand your question or what you think are the differences between your two example or how it solves the if in factory problem. Could you explain your view in more detail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zen</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-987</link>
		<dc:creator>Zen</dc:creator>
		<pubDate>Fri, 08 May 2009 18:45:06 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-987</guid>
		<description>@Ionut, Misko
First Misko, thanks for a more than excellent blog. I came about it today, and I can&#039;t stop reading. I&#039;ve learned  a  great lot.

To the problem with factory logic. You could avoid it by creating multiple get methods. Couldn&#039;t you?

An example:

Connection con
if (something is true) then
   con = Factory.getDatabaseConnection()
else
  con = Factory.getFileBasedConnection()
End if


Misko, (and you other experts), would you consider the above be a better way of doing things than the next example below?

Example 2:

Connection con
if (something is true) then
   con = Factory.getConnection(&#039;Database&#039;)
else
  con = Factory.getConnection(&#039;File&#039;)
End if
</description>
		<content:encoded><![CDATA[<p>@Ionut, Misko<br />
First Misko, thanks for a more than excellent blog. I came about it today, and I can&#8217;t stop reading. I&#8217;ve learned  a  great lot.</p>
<p>To the problem with factory logic. You could avoid it by creating multiple get methods. Couldn&#8217;t you?</p>
<p>An example:</p>
<p>Connection con<br />
if (something is true) then<br />
   con = Factory.getDatabaseConnection()<br />
else<br />
  con = Factory.getFileBasedConnection()<br />
End if</p>
<p>Misko, (and you other experts), would you consider the above be a better way of doing things than the next example below?</p>
<p>Example 2:</p>
<p>Connection con<br />
if (something is true) then<br />
   con = Factory.getConnection(&#8217;Database&#8217;)<br />
else<br />
  con = Factory.getConnection(&#8217;File&#8217;)<br />
End if</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: igorbrejc.net &#187; Fresh Catch For April 8th</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-849</link>
		<dc:creator>igorbrejc.net &#187; Fresh Catch For April 8th</dc:creator>
		<pubDate>Wed, 08 Apr 2009 06:04:20 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-849</guid>
		<description>[...] Collaborator vs. the Factory [...]</description>
		<content:encoded><![CDATA[<p>[...] Collaborator vs. the Factory [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: German</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-842</link>
		<dc:creator>German</dc:creator>
		<pubDate>Sun, 05 Apr 2009 18:02:16 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-842</guid>
		<description>May I humbly request that you don&#039;t write &quot;than&quot; when you mean &quot;then&quot;? Sorry about that. The blog is great and I think every Java developer should give it a good read. </description>
		<content:encoded><![CDATA[<p>May I humbly request that you don&#8217;t write &#8220;than&#8221; when you mean &#8220;then&#8221;? Sorry about that. The blog is great and I think every Java developer should give it a good read. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: misko</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-830</link>
		<dc:creator>misko</dc:creator>
		<pubDate>Tue, 31 Mar 2009 14:49:07 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-830</guid>
		<description>@Ionut,

I think you are on the right track. Sometimes a factory needs to insatiate different things depending on some arguments. This is the only time when I will say that trivial if statements are probably ok. But in general you are right. Let the factory control the wiring process keeping the ifs out of it (as much as possible).</description>
		<content:encoded><![CDATA[<p>@Ionut,</p>
<p>I think you are on the right track. Sometimes a factory needs to insatiate different things depending on some arguments. This is the only time when I will say that trivial if statements are probably ok. But in general you are right. Let the factory control the wiring process keeping the ifs out of it (as much as possible).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ionut G. Stan</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-829</link>
		<dc:creator>Ionut G. Stan</dc:creator>
		<pubDate>Tue, 31 Mar 2009 14:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-829</guid>
		<description>Great post Misko. I&#039;ve recently discovered your blog and I must say I&#039;m very glad about it. I have one question though (as anyone else)...In your example, the factory is lucky enough to know everything is needed for the call graph. But in my experience I saw there are times when objects are created based on business logic. So, some object requires a certain object, with a certain interface. The tricky part is that the concrete object&#160; type is determined at runtime in some business logic code.What should I do in this case?I&#039;m trying my luck with a little idea, maybe I&#039;m on the right track.I for one, would create yet another factory, which takes as an argument the result of the business logic processing and decides which object to return. This factory already has a pool of object from which to return the appropriate object based on the passed argument. The pool would be created in the main factory (concrete objects passed as arguments to the factory). My factory would then be passed as an argument to the appropriate object in the same main factory.Is that OK? Does it have shortcomings?I remember you said factories should not present logic, whereas this one does have at least a switch structure (in Java).</description>
		<content:encoded><![CDATA[<p>Great post Misko. I&#8217;ve recently discovered your blog and I must say I&#8217;m very glad about it. I have one question though (as anyone else)&#8230;In your example, the factory is lucky enough to know everything is needed for the call graph. But in my experience I saw there are times when objects are created based on business logic. So, some object requires a certain object, with a certain interface. The tricky part is that the concrete object&nbsp; type is determined at runtime in some business logic code.What should I do in this case?I&#8217;m trying my luck with a little idea, maybe I&#8217;m on the right track.I for one, would create yet another factory, which takes as an argument the result of the business logic processing and decides which object to return. This factory already has a pool of object from which to return the appropriate object based on the passed argument. The pool would be created in the main factory (concrete objects passed as arguments to the factory). My factory would then be passed as an argument to the appropriate object in the same main factory.Is that OK? Does it have shortcomings?I remember you said factories should not present logic, whereas this one does have at least a switch structure (in Java).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edd Grant</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-828</link>
		<dc:creator>Edd Grant</dc:creator>
		<pubDate>Tue, 31 Mar 2009 12:42:45 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-828</guid>
		<description>I like your thinking here, presumably the objects that the servlet uses in it&#039;s guise as a factory could even be provided via dependency injection where appropriate.One thought, I wonder if it would beneficial to still write separate servlet and factory classes in order to provide cleaner separation from a testing point of view? I&#039;d imagine that doing this would effectively draw a line between the servlet and factory classes, ensuring that any servlet specific ties or test setup requirements would not be present when testing the factory class? Any thoughts on this?</description>
		<content:encoded><![CDATA[<p>I like your thinking here, presumably the objects that the servlet uses in it&#8217;s guise as a factory could even be provided via dependency injection where appropriate.One thought, I wonder if it would beneficial to still write separate servlet and factory classes in order to provide cleaner separation from a testing point of view? I&#8217;d imagine that doing this would effectively draw a line between the servlet and factory classes, ensuring that any servlet specific ties or test setup requirements would not be present when testing the factory class? Any thoughts on this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oleg</title>
		<link>http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/comment-page-1/#comment-827</link>
		<dc:creator>Oleg</dc:creator>
		<pubDate>Tue, 31 Mar 2009 12:09:30 +0000</pubDate>
		<guid isPermaLink="false">http://misko.hevery.com/?p=440#comment-827</guid>
		<description>Hi, Misko.I would like to see a larger (working) piece of code or a project, designed using principles you describe on this blog. I really want to &quot;feel&quot; such code under my fingertips ;-)Could you point me to some?Thanks.Oleg</description>
		<content:encoded><![CDATA[<p>Hi, Misko.I would like to see a larger (working) piece of code or a project, designed using principles you describe on this blog. I really want to &#8220;feel&#8221; such code under my fingertips <img src='http://misko.hevery.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> Could you point me to some?Thanks.Oleg</p>
]]></content:encoded>
	</item>
</channel>
</rss>
