<?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: I recant my IoC! IoC containers in dynamic languages are silly.</title>
	<atom:link href="http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/</link>
	<description>The small minded meanderings of the confused</description>
	<lastBuildDate>Mon, 15 Apr 2013 15:10:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Petar Shomov</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-124</link>
		<dc:creator>Petar Shomov</dc:creator>
		<pubDate>Fri, 20 Nov 2009 23:27:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-124</guid>
		<description>Hi Ryan,

Thank you for taking the time to asnwer my concerns. I find that all of the resolutions you offered were too much sacrificy for my taste and actually summarize why I always prefer DI over Service Locator(I am not sure what I was thinking but I realized outputselect and saveoutput methods are actually participatng in a service locator pattern. Have to read blogs in the morning, when fresh ...). Anyways, thanx for the discussion, I am always curios about other people&#039;s perspective, so keep these posts coming ;) </description>
		<content:encoded><![CDATA[<p>Hi Ryan,</p>
<p>Thank you for taking the time to asnwer my concerns. I find that all of the resolutions you offered were too much sacrificy for my taste and actually summarize why I always prefer DI over Service Locator(I am not sure what I was thinking but I realized outputselect and saveoutput methods are actually participatng in a service locator pattern. Have to read blogs in the morning, when fresh &#8230;). Anyways, thanx for the discussion, I am always curios about other people&#8217;s perspective, so keep these posts coming <img src='http://lostechies.com/ryansvihla/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Svihla</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-123</link>
		<dc:creator>Ryan Svihla</dc:creator>
		<pubDate>Thu, 19 Nov 2009 23:03:23 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-123</guid>
		<description>@Petar good questions

1) make a module call it &quot;IoCConfig&quot; and use it the same way you&#039;d do your IoC registration.  This same issue could be related to how you use an IoC container. Use it in a dumb way and you&#039;ll have to recall the code over and over again.

2)Again this is the same issue you have with IoC controllers, you have multiple implementations of the same interface, you have to make special allowances for custom resolution. _in either approach you have to do custom code to switch which interface implementation is in use_. I made Output a specific empty class for a reason, its a good stand in for an interface (and when people see Output has no code body it especially hits home that a &quot;strategy&quot; needs to be selected&quot;.  Finally in this case I&#039;d suggest a factory that hands off the correct instance of said class at a given time..which I&#039;d be inclined to use as a solution in static languages in complex enough cases.

3) See #2 , again custom factories are more suitable here, in python or C#.  The reason IoC containers tend to handle this is because its the only place you typically get access to your &quot;entire run time&quot; barring some magic hackery in the CLR with the profiler.  When you _already_ have access to your entire runtime, you can just use the natural methods to do these things.

4) No I&#039;m assuming my types have a constructor with the same signature (important distinction,and when not using DI, your constructors are much more manageable). If I really need to do dynamic resolution of types with differing signatures I again wrap this in a custom factory and it would have a similar algorithm to what you use in an IoC container (if you&#039;ve never written one I highly encourage it, its not hard and it gives you a unique perspective), but I&#039;d have no desire to put my entire runtime in it, or maintain placing my entire runtime in the IoC. only the bits I care about that need this special custom functionality, and its rare at best.

PS I know you said ignore AOP but as a side note I&#039;m not advocating decorators, and i think by themselves are a poor use of AOP in my opinion (same way attributes are in C#). I just used the wrap decorator in my code to apply interceptors on the fly (which can be done by rule matching and I only wrap what I want), otherwise the approach is I feel a Python equivalent to Windsor&#039;s internal implementation of DynProxy and Interceptors.

 </description>
		<content:encoded><![CDATA[<p>@Petar good questions</p>
<p>1) make a module call it &#8220;IoCConfig&#8221; and use it the same way you&#8217;d do your IoC registration.  This same issue could be related to how you use an IoC container. Use it in a dumb way and you&#8217;ll have to recall the code over and over again.</p>
<p>2)Again this is the same issue you have with IoC controllers, you have multiple implementations of the same interface, you have to make special allowances for custom resolution. _in either approach you have to do custom code to switch which interface implementation is in use_. I made Output a specific empty class for a reason, its a good stand in for an interface (and when people see Output has no code body it especially hits home that a &#8220;strategy&#8221; needs to be selected&#8221;.  Finally in this case I&#8217;d suggest a factory that hands off the correct instance of said class at a given time..which I&#8217;d be inclined to use as a solution in static languages in complex enough cases.</p>
<p>3) See #2 , again custom factories are more suitable here, in python or C#.  The reason IoC containers tend to handle this is because its the only place you typically get access to your &#8220;entire run time&#8221; barring some magic hackery in the CLR with the profiler.  When you _already_ have access to your entire runtime, you can just use the natural methods to do these things.</p>
<p>4) No I&#8217;m assuming my types have a constructor with the same signature (important distinction,and when not using DI, your constructors are much more manageable). If I really need to do dynamic resolution of types with differing signatures I again wrap this in a custom factory and it would have a similar algorithm to what you use in an IoC container (if you&#8217;ve never written one I highly encourage it, its not hard and it gives you a unique perspective), but I&#8217;d have no desire to put my entire runtime in it, or maintain placing my entire runtime in the IoC. only the bits I care about that need this special custom functionality, and its rare at best.</p>
<p>PS I know you said ignore AOP but as a side note I&#8217;m not advocating decorators, and i think by themselves are a poor use of AOP in my opinion (same way attributes are in C#). I just used the wrap decorator in my code to apply interceptors on the fly (which can be done by rule matching and I only wrap what I want), otherwise the approach is I feel a Python equivalent to Windsor&#8217;s internal implementation of DynProxy and Interceptors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petar Shomov</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-122</link>
		<dc:creator>Petar Shomov</dc:creator>
		<pubDate>Thu, 19 Nov 2009 22:42:03 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-122</guid>
		<description>Hi Ryan,

I think I phrased my question the wrong way. I will try again, but this time I will list the issues I have with the code above:

1. the code is hard-coded to instantiating the type stored in outputlib.Output. If I have to reuse this code again I have to make this module and variable existent and store the type there

2. if I want to make two instances of the code (in this case it looks like a method) that use two different methods of rendering I have to change renderers in outputlib.Output in between (or something like that) the method calls

3. In multi-threaded scenarios (no idea how is threading in python) point #2 becomes something I am not ready to deal with

4. This one is a bit on the side, but you are also instantiating the type in your method assuming it takes no parameters in the constructor.

My current thinking is that DI takes care of these things no metter the language. You could do exactly the same thing you have done here but in C# and it will be equally mockable and testable, it&#039;s just that I think it will be a lot cleaner if you just passed that renderer instance as a parameter ;)

What am I missing Ryan? ;)

Best regards,

Petar

P.S. Let&#039;s leave AOP on the side for now, python decorators are interesting approach but I am still not completely sure how I feel about them</description>
		<content:encoded><![CDATA[<p>Hi Ryan,</p>
<p>I think I phrased my question the wrong way. I will try again, but this time I will list the issues I have with the code above:</p>
<p>1. the code is hard-coded to instantiating the type stored in outputlib.Output. If I have to reuse this code again I have to make this module and variable existent and store the type there</p>
<p>2. if I want to make two instances of the code (in this case it looks like a method) that use two different methods of rendering I have to change renderers in outputlib.Output in between (or something like that) the method calls</p>
<p>3. In multi-threaded scenarios (no idea how is threading in python) point #2 becomes something I am not ready to deal with</p>
<p>4. This one is a bit on the side, but you are also instantiating the type in your method assuming it takes no parameters in the constructor.</p>
<p>My current thinking is that DI takes care of these things no metter the language. You could do exactly the same thing you have done here but in C# and it will be equally mockable and testable, it&#8217;s just that I think it will be a lot cleaner if you just passed that renderer instance as a parameter <img src='http://lostechies.com/ryansvihla/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>What am I missing Ryan? <img src='http://lostechies.com/ryansvihla/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Best regards,</p>
<p>Petar</p>
<p>P.S. Let&#8217;s leave AOP on the side for now, python decorators are interesting approach but I am still not completely sure how I feel about them</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Svihla</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-121</link>
		<dc:creator>Ryan Svihla</dc:creator>
		<pubDate>Wed, 18 Nov 2009 00:44:47 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-121</guid>
		<description>@Petar. 
Ignore service locator, it was an easy example to show for simple contextual resolution. Doing a proper override of Dependency Resolution in Windsor has been done many times in other blog posts and is worthy of a blog post itself.
 
What is the point of dependency injection and Inversion of Control? We get testability, easy ability to override behavior in our _actual_ codebase,  If you&#039;re doing DI and IoC for any other reason I&#039;m glad to recant my recant and hear what it is.

Why do we use IoC containers themselves? having a nice thing to prevent us from having to write a ton of factory classes, since we have to use DI to keep ourselves from tightly coupling our code.  Also, we get for low cost nice things like AOP, and contextual resolution.

In dynamic languages you get all that _even when you call new_ . You still get testability and mockability, look at the examples above, I&#039;m actually overriding the entire class object, so now _every_ time you call new on that class that code you will get the new value.  This sort of functionality you get by using DI, dynproxy, and intercepters. Which involves a big chunk of code.

Now if I can _STILL_ have testability that&#039;s even stronger than the best mocking libraries in static languages, have low coupling always, and I can in a few lines of code apply logging, security, to entire modules and code bases (which is why I&#039;m using an IoC container in the first place) why would I want to have another IoC container?



</description>
		<content:encoded><![CDATA[<p>@Petar.<br />
Ignore service locator, it was an easy example to show for simple contextual resolution. Doing a proper override of Dependency Resolution in Windsor has been done many times in other blog posts and is worthy of a blog post itself.</p>
<p>What is the point of dependency injection and Inversion of Control? We get testability, easy ability to override behavior in our _actual_ codebase,  If you&#8217;re doing DI and IoC for any other reason I&#8217;m glad to recant my recant and hear what it is.</p>
<p>Why do we use IoC containers themselves? having a nice thing to prevent us from having to write a ton of factory classes, since we have to use DI to keep ourselves from tightly coupling our code.  Also, we get for low cost nice things like AOP, and contextual resolution.</p>
<p>In dynamic languages you get all that _even when you call new_ . You still get testability and mockability, look at the examples above, I&#8217;m actually overriding the entire class object, so now _every_ time you call new on that class that code you will get the new value.  This sort of functionality you get by using DI, dynproxy, and intercepters. Which involves a big chunk of code.</p>
<p>Now if I can _STILL_ have testability that&#8217;s even stronger than the best mocking libraries in static languages, have low coupling always, and I can in a few lines of code apply logging, security, to entire modules and code bases (which is why I&#8217;m using an IoC container in the first place) why would I want to have another IoC container?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petar Shomov</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-120</link>
		<dc:creator>Petar Shomov</dc:creator>
		<pubDate>Wed, 18 Nov 2009 00:27:44 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-120</guid>
		<description>Hi,

I am also in the process of learning Python/Django and trying to let go of my &quot;static thinking&quot; but I am not sure I completely understand your point. Looking at the registration sample with the renderers I can see the registration part but I am not seeing how is the dependency injection part going to happen. Let&#039;s forget about the service locator for now, shall we ;)

Mental Note to self: self, stop fooling around and check out python spring.

Besrt regards,

Petar </description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am also in the process of learning Python/Django and trying to let go of my &#8220;static thinking&#8221; but I am not sure I completely understand your point. Looking at the registration sample with the renderers I can see the registration part but I am not seeing how is the dependency injection part going to happen. Let&#8217;s forget about the service locator for now, shall we <img src='http://lostechies.com/ryansvihla/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Mental Note to self: self, stop fooling around and check out python spring.</p>
<p>Besrt regards,</p>
<p>Petar </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Corey Coogan</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-119</link>
		<dc:creator>Corey Coogan</dc:creator>
		<pubDate>Tue, 17 Nov 2009 18:10:25 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-119</guid>
		<description>Oops, I should have read your post first.  I see how you are achieving it, and that&#039;s what I first suspected.  I do this with certain keys/types to resolve the correct interface. 

When you call it &quot;contextual&quot; it sounded so much fancier and thought there might be some cool magic I didn&#039;t know about.</description>
		<content:encoded><![CDATA[<p>Oops, I should have read your post first.  I see how you are achieving it, and that&#8217;s what I first suspected.  I do this with certain keys/types to resolve the correct interface. </p>
<p>When you call it &#8220;contextual&#8221; it sounded so much fancier and thought there might be some cool magic I didn&#8217;t know about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Corey Coogan</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-118</link>
		<dc:creator>Corey Coogan</dc:creator>
		<pubDate>Tue, 17 Nov 2009 18:07:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-118</guid>
		<description>Great article Ryan.  I&#039;ve been using Castle and StructureMap, but I know I&#039;m still not fully utilizing the containers to their fullest potential.  

Can you explain how you achieve this? 

&quot;give me hooks for contextual resolution&quot; </description>
		<content:encoded><![CDATA[<p>Great article Ryan.  I&#8217;ve been using Castle and StructureMap, but I know I&#8217;m still not fully utilizing the containers to their fullest potential.  </p>
<p>Can you explain how you achieve this? </p>
<p>&#8220;give me hooks for contextual resolution&#8221; </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Svihla</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-117</link>
		<dc:creator>Ryan Svihla</dc:creator>
		<pubDate>Tue, 17 Nov 2009 15:11:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-117</guid>
		<description>You got it. It replaces what we&#039;re used to with containers and _all_ new instances of Output will use the type it&#039;s been assigned.

You have &quot;strategy&quot; without explicitly
 making it clear, it&#039;s like one big global IoC container.</description>
		<content:encoded><![CDATA[<p>You got it. It replaces what we&#8217;re used to with containers and _all_ new instances of Output will use the type it&#8217;s been assigned.</p>
<p>You have &#8220;strategy&#8221; without explicitly<br />
 making it clear, it&#8217;s like one big global IoC container.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua Flanagan</title>
		<link>http://lostechies.com/ryansvihla/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly/#comment-116</link>
		<dc:creator>Joshua Flanagan</dc:creator>
		<pubDate>Tue, 17 Nov 2009 13:17:02 +0000</pubDate>
		<guid isPermaLink="false">/blogs/rssvihla/archive/2009/11/16/i-recant-my-ioc-ioc-containers-in-dynamic-languages-are-silly.aspx#comment-116</guid>
		<description>You lost me on the outputselect example. Can you explain how that demonstrates dynamic extensibility? My initial impression is that it is just a hardcoded switch statement that could easily be replicated in C#.
I think you might be showing how you are modifying outputlib after the fact, but that isn&#039;t immediately clear. Am I on the right track?</description>
		<content:encoded><![CDATA[<p>You lost me on the outputselect example. Can you explain how that demonstrates dynamic extensibility? My initial impression is that it is just a hardcoded switch statement that could easily be replicated in C#.<br />
I think you might be showing how you are modifying outputlib after the fact, but that isn&#8217;t immediately clear. Am I on the right track?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
