<?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 for Black Sheep</title>
	<atom:link href="http://blacksheep.parry.org/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://blacksheep.parry.org</link>
	<description>The soapbox of Chad and Elisa Parry</description>
	<lastBuildDate>Thu, 08 Dec 2011 10:09:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>Comment on DIY-DI by Dependency Injection &#124; Mathieu ROIG - Portfolio</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-603</link>
		<dc:creator>Dependency Injection &#124; Mathieu ROIG - Portfolio</dc:creator>
		<pubDate>Thu, 08 Dec 2011 10:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-603</guid>
		<description>[...] Objective-C This post is an Objective-C adaptation of Do it your self Dependency Injection (Java) .The article is a very well done and comprehensive introduction for the manual DI. I find that it [...]</description>
		<content:encoded><![CDATA[<p>[...] Objective-C This post is an Objective-C adaptation of Do it your self Dependency Injection (Java) .The article is a very well done and comprehensive introduction for the manual DI. I find that it [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Superheroes by Elisa</title>
		<link>http://blacksheep.parry.org/archives/superheroes/comment-page-1#comment-523</link>
		<dc:creator>Elisa</dc:creator>
		<pubDate>Mon, 10 Oct 2011 03:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=383#comment-523</guid>
		<description>It helps that we weren&#039;t driving for 2 1/2 years of the time we were practicing our superhero skills.</description>
		<content:encoded><![CDATA[<p>It helps that we weren&#8217;t driving for 2 1/2 years of the time we were practicing our superhero skills.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Plan of Truth by Black Sheep » Plan of Truth &#124; Gospel Feeds</title>
		<link>http://blacksheep.parry.org/archives/plan-of-truth/comment-page-1#comment-509</link>
		<dc:creator>Black Sheep » Plan of Truth &#124; Gospel Feeds</dc:creator>
		<pubDate>Tue, 04 Oct 2011 07:26:07 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=1134#comment-509</guid>
		<description>[...] Sheep » Plan of Truth 3 de outubro de 2011    Origem: http://blacksheep.parry.org/archives/plan-of-truth  A sermon in Alma 32 described how truths are learned through experimentation. By the results of [...]</description>
		<content:encoded><![CDATA[<p>[...] Sheep » Plan of Truth 3 de outubro de 2011    Origem: <a href="http://blacksheep.parry.org/archives/plan-of-truth" rel="nofollow">http://blacksheep.parry.org/archives/plan-of-truth</a>  A sermon in Alma 32 described how truths are learned through experimentation. By the results of [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by WW</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-449</link>
		<dc:creator>WW</dc:creator>
		<pubDate>Mon, 25 Jul 2011 12:59:14 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-449</guid>
		<description>If you end up nesting scopes within each other, your static injector code may unusable from the outer scope.  I don&#039;t trust myself to predict the future, and whenever you use static you are saying you&#039;re only ever going to use it like that.  Hence, you only use it when forced to by the calling code (including the JVM).

I know you&#039;ve said the injector code is untestable, but I do have tests where the object under test is provided to me by the factory.  In this case, I sometimes extend the factory with an anonymous class from the test and override inject methods to use as test doubles.

PS. If you haven&#039;t seen the New Zealand move Black Sheep, you should watch it, it&#039;s a classic.</description>
		<content:encoded><![CDATA[<p>If you end up nesting scopes within each other, your static injector code may unusable from the outer scope.  I don&#8217;t trust myself to predict the future, and whenever you use static you are saying you&#8217;re only ever going to use it like that.  Hence, you only use it when forced to by the calling code (including the JVM).</p>
<p>I know you&#8217;ve said the injector code is untestable, but I do have tests where the object under test is provided to me by the factory.  In this case, I sometimes extend the factory with an anonymous class from the test and override inject methods to use as test doubles.</p>
<p>PS. If you haven&#8217;t seen the New Zealand move Black Sheep, you should watch it, it&#8217;s a classic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by Chad Parry</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-440</link>
		<dc:creator>Chad Parry</dc:creator>
		<pubDate>Thu, 21 Jul 2011 02:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-440</guid>
		<description>Normally static methods are evil because the calling code becomes untestable. But what if the static is only called from the glue code? In that case, it only looks evil because we are trained to hate it, but it is perfectly safe. Instead of having a constructor that stores multiple arguments into fields, you could have have a static method that takes all those parameters directly. It would cut down on boilerplate code.

It&#039;s only safe to do that if the injector is calling the static method and giving the result to the application code. Specifically, you can&#039;t do it if the class containing the static method were ever going to be injected into the application code itself. And you also can&#039;t ever do it if you want interoperability with non-DI code, which is what usually dissuades me.

Let me know if my thinking on this seems unclear, and I could put together a code sample.</description>
		<content:encoded><![CDATA[<p>Normally static methods are evil because the calling code becomes untestable. But what if the static is only called from the glue code? In that case, it only looks evil because we are trained to hate it, but it is perfectly safe. Instead of having a constructor that stores multiple arguments into fields, you could have have a static method that takes all those parameters directly. It would cut down on boilerplate code.</p>
<p>It&#8217;s only safe to do that if the injector is calling the static method and giving the result to the application code. Specifically, you can&#8217;t do it if the class containing the static method were ever going to be injected into the application code itself. And you also can&#8217;t ever do it if you want interoperability with non-DI code, which is what usually dissuades me.</p>
<p>Let me know if my thinking on this seems unclear, and I could put together a code sample.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by WW</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-438</link>
		<dc:creator>WW</dc:creator>
		<pubDate>Wed, 20 Jul 2011 06:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-438</guid>
		<description>&gt;My code also ends up containing a lot of one-method classes. &gt;Sometimes I’m tempted to just make them static methods, so I &gt;don’t have to write boilerplate code for all the class’s 
&gt;fields.

I didn&#039;t really understand that.  I consider static an evil reserved for main().  Most of our business logic classes consist of a constructor (which just stores values in member variables) and a single method that does something.  Our entity/value classes have a constructor and getters.  Sometimes they have setters as well.  The factory classes contain many protected inject*() methods.  Nothing is static except where our code is invoked from externally.

What type of class are you talking about that you would make static?  Factory, entity or service?</description>
		<content:encoded><![CDATA[<p>&gt;My code also ends up containing a lot of one-method classes. &gt;Sometimes I’m tempted to just make them static methods, so I &gt;don’t have to write boilerplate code for all the class’s<br />
&gt;fields.</p>
<p>I didn&#8217;t really understand that.  I consider static an evil reserved for main().  Most of our business logic classes consist of a constructor (which just stores values in member variables) and a single method that does something.  Our entity/value classes have a constructor and getters.  Sometimes they have setters as well.  The factory classes contain many protected inject*() methods.  Nothing is static except where our code is invoked from externally.</p>
<p>What type of class are you talking about that you would make static?  Factory, entity or service?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by Chad Parry</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-428</link>
		<dc:creator>Chad Parry</dc:creator>
		<pubDate>Sat, 16 Jul 2011 02:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-428</guid>
		<description>@WW, mainly I&#039;m glad that you found something that works for you. As far as I understand your plan, you start off with a static method invocation, &quot;newFactoryForCustomer,&quot; and then from there you invoke instance methods on the result. I like to do the same thing. I would probably write it, &quot;Factory factory = injectFactory(applicationScope, customerScope);&quot; but I think both accomplish the same thing. Thanks for sharing your technique.

My code also ends up containing a lot of one-method classes. Sometimes I&#039;m tempted to just make them static methods, so I don&#039;t have to write boilerplate code for all the class&#039;s fields. The only reason I don&#039;t is so that the application will still be marginally testable if someone with a non-DI client tries to reuse my code. In a pure DI application, static methods can still be testable as long as they are only called from the glue code, not the business logic.</description>
		<content:encoded><![CDATA[<p>@WW, mainly I&#8217;m glad that you found something that works for you. As far as I understand your plan, you start off with a static method invocation, &#8220;newFactoryForCustomer,&#8221; and then from there you invoke instance methods on the result. I like to do the same thing. I would probably write it, &#8220;Factory factory = injectFactory(applicationScope, customerScope);&#8221; but I think both accomplish the same thing. Thanks for sharing your technique.</p>
<p>My code also ends up containing a lot of one-method classes. Sometimes I&#8217;m tempted to just make them static methods, so I don&#8217;t have to write boilerplate code for all the class&#8217;s fields. The only reason I don&#8217;t is so that the application will still be marginally testable if someone with a non-DI client tries to reuse my code. In a pure DI application, static methods can still be testable as long as they are only called from the glue code, not the business logic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by WW</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-425</link>
		<dc:creator>WW</dc:creator>
		<pubDate>Fri, 15 Jul 2011 09:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-425</guid>
		<description>Hi Chad,

I commented previously on Misko&#039;s blog.  I wrote a non-trivial piece of code and I&#039;m convinced the factory methods should not be static.

In the simple case, our top level code then looks like this:

    Factory factory = new Factory( scope );
    Processor processor = factory.getProcessor();
    processor.process();

We are working in a hosted-service environment and different customers want different things.  Therefore, this code actually becomes:

    Factory factory = newFactoryForCustomer( customer, scope );
    Processor processor = factory.getProcessor();
    processor.process();

Where newFactoryForCustomer() returns different instances depending on the customer.  These instances extend a base factory.  When a customer wants something special, we override an inject*() method in their specific factory.

I also noticed that I ended up with alot of classes containing a constructor and a single method.  Many of these ended up implementing Provider.  I was comfortable with this because the coupling is very loose, and they are easy to replace with test doubles.

Cheers,
Will</description>
		<content:encoded><![CDATA[<p>Hi Chad,</p>
<p>I commented previously on Misko&#8217;s blog.  I wrote a non-trivial piece of code and I&#8217;m convinced the factory methods should not be static.</p>
<p>In the simple case, our top level code then looks like this:</p>
<p>    Factory factory = new Factory( scope );<br />
    Processor processor = factory.getProcessor();<br />
    processor.process();</p>
<p>We are working in a hosted-service environment and different customers want different things.  Therefore, this code actually becomes:</p>
<p>    Factory factory = newFactoryForCustomer( customer, scope );<br />
    Processor processor = factory.getProcessor();<br />
    processor.process();</p>
<p>Where newFactoryForCustomer() returns different instances depending on the customer.  These instances extend a base factory.  When a customer wants something special, we override an inject*() method in their specific factory.</p>
<p>I also noticed that I ended up with alot of classes containing a constructor and a single method.  Many of these ended up implementing Provider.  I was comfortable with this because the coupling is very loose, and they are easy to replace with test doubles.</p>
<p>Cheers,<br />
Will</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Dating by Stinson</title>
		<link>http://blacksheep.parry.org/archives/dating/comment-page-1#comment-381</link>
		<dc:creator>Stinson</dc:creator>
		<pubDate>Mon, 27 Jun 2011 01:25:02 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=450#comment-381</guid>
		<description>I guess we both had good timing, eh?</description>
		<content:encoded><![CDATA[<p>I guess we both had good timing, eh?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on DIY-DI by Chad Parry</title>
		<link>http://blacksheep.parry.org/archives/diy-di/comment-page-1#comment-313</link>
		<dc:creator>Chad Parry</dc:creator>
		<pubDate>Sat, 23 Apr 2011 01:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://blacksheep.parry.org/?p=329#comment-313</guid>
		<description>Peter, for better or worse, DI leads you towards a more functional style of programming. Your typical service objects have one method and no persistent state. Your data is immutable. You don&#039;t really follow all the OO patterns anymore, because they don&#039;t fare as well when you are writing tests.</description>
		<content:encoded><![CDATA[<p>Peter, for better or worse, DI leads you towards a more functional style of programming. Your typical service objects have one method and no persistent state. Your data is immutable. You don&#8217;t really follow all the OO patterns anymore, because they don&#8217;t fare as well when you are writing tests.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

