<?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: Dependency Injection in ASP.NET MVC: Controllers</title>
	<atom:link href="http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Wed, 19 Jun 2013 17:39: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: RyanAnderson</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2357</link>
		<dc:creator>RyanAnderson</dc:creator>
		<pubDate>Fri, 23 Jul 2010 03:13:06 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2357</guid>
		<description>JB - Disregard.... Just read Henning Anderssen post, and I concur... Likelyhood of DI con swap is nil... And IContainer is valuable... Gotta Love JM!</description>
		<content:encoded><![CDATA[<p>JB &#8211; Disregard&#8230;. Just read Henning Anderssen post, and I concur&#8230; Likelyhood of DI con swap is nil&#8230; And IContainer is valuable&#8230; Gotta Love JM!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RyanAnderson</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2356</link>
		<dc:creator>RyanAnderson</dc:creator>
		<pubDate>Fri, 23 Jul 2010 03:09:55 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2356</guid>
		<description>JB - If you encapsulate DI into its own library, you can wrap up your DI container and loosen the dependency on a specific DI container. 

Something like this in your App_Start,
ControllerBuilder.Current.SetControllerFactory(new MyIsolatedDiContainerLib.StructureMapControllerFactory());
(excuse the poor naming conv...)
This way the reference to StructureMap could be eliminated.

That way, if another DI flavor comes that you like better, you merely need to swap it out in you isolated DI Lib. 
Like what you guys do in CodeCamp Server, with the StructureMapControllerFactory in the isolated DI Lib.
</description>
		<content:encoded><![CDATA[<p>JB &#8211; If you encapsulate DI into its own library, you can wrap up your DI container and loosen the dependency on a specific DI container. </p>
<p>Something like this in your App_Start,<br />
ControllerBuilder.Current.SetControllerFactory(new MyIsolatedDiContainerLib.StructureMapControllerFactory());<br />
(excuse the poor naming conv&#8230;)<br />
This way the reference to StructureMap could be eliminated.</p>
<p>That way, if another DI flavor comes that you like better, you merely need to swap it out in you isolated DI Lib.<br />
Like what you guys do in CodeCamp Server, with the StructureMapControllerFactory in the isolated DI Lib.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2355</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Wed, 05 May 2010 12:58:31 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2355</guid>
		<description>@ulu

Good call!  Yeah, I just ran into this the other day and was wondering the right way to go.  The base class provides a nice implementation.</description>
		<content:encoded><![CDATA[<p>@ulu</p>
<p>Good call!  Yeah, I just ran into this the other day and was wondering the right way to go.  The base class provides a nice implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ulu</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2354</link>
		<dc:creator>ulu</dc:creator>
		<pubDate>Wed, 05 May 2010 09:33:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2354</guid>
		<description>Rather than returning a null, I return base.GetControllerInstance(). This way, I get a more meaningful exception when I mistype the controller name.</description>
		<content:encoded><![CDATA[<p>Rather than returning a null, I return base.GetControllerInstance(). This way, I get a more meaningful exception when I mistype the controller name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Nicola</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2353</link>
		<dc:creator>Chris Nicola</dc:creator>
		<pubDate>Sat, 01 May 2010 19:11:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2353</guid>
		<description>Sharp Architecture has this feature out of the box using Windsor.  I definitely recommend MVC and IoC newbs check it out.</description>
		<content:encoded><![CDATA[<p>Sharp Architecture has this feature out of the box using Windsor.  I definitely recommend MVC and IoC newbs check it out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mac</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2352</link>
		<dc:creator>Mac</dc:creator>
		<pubDate>Tue, 27 Apr 2010 20:28:44 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2352</guid>
		<description>I found the same thing with the common service locator. It&#039;s a great idea in principle but it&#039;s too restrictive in trying to utilise the flexibility of an IoC like structuremap. The inability to occasionally inject/override parameters pretty much killed it for me.

Agree with Henning about the testing with the IContainer, we switched to that approach and so far it works very well.
</description>
		<content:encoded><![CDATA[<p>I found the same thing with the common service locator. It&#8217;s a great idea in principle but it&#8217;s too restrictive in trying to utilise the flexibility of an IoC like structuremap. The inability to occasionally inject/override parameters pretty much killed it for me.</p>
<p>Agree with Henning about the testing with the IContainer, we switched to that approach and so far it works very well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Tavares</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2351</link>
		<dc:creator>Chris Tavares</dc:creator>
		<pubDate>Tue, 27 Apr 2010 20:19:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2351</guid>
		<description>CommonServiceLocator was intended for use by libraries that needed / wanted DI services, but did not want to force their choice of container on their consumers. It was never intended to be used in applications. I agree, there&#039;s pretty much zero reason to switch containers. And heck, if you did it right, changing the container wouldn&#039;t actually touch that much code.
</description>
		<content:encoded><![CDATA[<p>CommonServiceLocator was intended for use by libraries that needed / wanted DI services, but did not want to force their choice of container on their consumers. It was never intended to be used in applications. I agree, there&#8217;s pretty much zero reason to switch containers. And heck, if you did it right, changing the container wouldn&#8217;t actually touch that much code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2350</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Tue, 27 Apr 2010 18:48:11 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2350</guid>
		<description>@Javier

I&#039;ve tried to use it in several of our projects (OSS or otherwise), and the answer has been (so far) a different design, or different configuration option like exposing Func&lt;T&gt; etc.  No one seems to even be developing on it either.</description>
		<content:encoded><![CDATA[<p>@Javier</p>
<p>I&#8217;ve tried to use it in several of our projects (OSS or otherwise), and the answer has been (so far) a different design, or different configuration option like exposing Func<t> etc.  No one seems to even be developing on it either.</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javier Lozano</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2349</link>
		<dc:creator>Javier Lozano</dc:creator>
		<pubDate>Tue, 27 Apr 2010 14:31:12 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2349</guid>
		<description>I think what you meant to say was &quot;Common Service Locator is pretty much useless for our needs&quot; :)

In all reality, yes, using your IoC to its fullest, is the definitely the way to go since you can build the app to best use different features the container provides.  

The big issue that some teams suffer is that they tend to get too hung up on the intersection between their IoC and the application rather than just embracing it and developing the app.</description>
		<content:encoded><![CDATA[<p>I think what you meant to say was &#8220;Common Service Locator is pretty much useless for our needs&#8221; <img src='http://lostechies.com/jimmybogard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In all reality, yes, using your IoC to its fullest, is the definitely the way to go since you can build the app to best use different features the container provides.  </p>
<p>The big issue that some teams suffer is that they tend to get too hung up on the intersection between their IoC and the application rather than just embracing it and developing the app.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henning Anderssen</title>
		<link>http://lostechies.com/jimmybogard/2010/04/27/dependency-injection-in-asp-net-mvc-controllers/#comment-2348</link>
		<dc:creator>Henning Anderssen</dc:creator>
		<pubDate>Tue, 27 Apr 2010 09:05:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2010/04/26/dependency-injection-in-asp-net-mvc-controllers.aspx#comment-2348</guid>
		<description>We had the same discussion recently on my current project, whether to use a common service locator / abstract away the IOC or to use the full power of an IOC.

We originally abstracted away Structuremap because of testing. At that time we only knew of ObjectFacotory.GetInstance and didnt know of the IContainer interface. Now that we know of the IContainer interface, the testability portion of abstracting away the IOC goes away. 
Another argument for abstracting away the IOC is the possibility for changing the IOC later in the project. &quot;Makes it easier to swap out the IOC&quot; and all that stuff. However, the likelyhood that you will EVER change the IOC is extremely small, especially when using Structuremap. And if you decide to swap out the IOC, you&#039;re likely to make changes in your code anyway.

We use the same method for creating our instances, and it works like a charm. There is only a few places where we have to resort to service location.</description>
		<content:encoded><![CDATA[<p>We had the same discussion recently on my current project, whether to use a common service locator / abstract away the IOC or to use the full power of an IOC.</p>
<p>We originally abstracted away Structuremap because of testing. At that time we only knew of ObjectFacotory.GetInstance and didnt know of the IContainer interface. Now that we know of the IContainer interface, the testability portion of abstracting away the IOC goes away.<br />
Another argument for abstracting away the IOC is the possibility for changing the IOC later in the project. &#8220;Makes it easier to swap out the IOC&#8221; and all that stuff. However, the likelyhood that you will EVER change the IOC is extremely small, especially when using Structuremap. And if you decide to swap out the IOC, you&#8217;re likely to make changes in your code anyway.</p>
<p>We use the same method for creating our instances, and it works like a charm. There is only a few places where we have to resort to service location.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
