<?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: Is this Better than Constructor Injection?</title>
	<atom:link href="http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/</link>
	<description>web development, tech reviews, tips, tricks, blogging</description>
	<lastBuildDate>Mon, 30 Aug 2010 23:56:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Chr4is</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-912</link>
		<dc:creator>Chr4is</dc:creator>
		<pubDate>Wed, 31 Dec 2008 11:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-912</guid>
		<description>I&#039;m with Mike.&lt;br&gt;&lt;br&gt;For example:&lt;br&gt;&lt;br&gt;In a simple MVC app. I have my CustomControllerFactory locate my controllers. My controllers have constructor dependencies on some Services. My Services have dependencies on infrastructure objects (repository, etc...).&lt;br&gt;&lt;br&gt;The only place my app has a dependency on the container is in the CustomControllerFactory. The container is totally transparent.&lt;br&gt;&lt;br&gt;Start throwing your service locator everywhere, you&#039;re bound to have a problem.</description>
		<content:encoded><![CDATA[<p>I&#39;m with Mike.</p>
<p>For example:</p>
<p>In a simple MVC app. I have my CustomControllerFactory locate my controllers. My controllers have constructor dependencies on some Services. My Services have dependencies on infrastructure objects (repository, etc&#8230;).</p>
<p>The only place my app has a dependency on the container is in the CustomControllerFactory. The container is totally transparent.</p>
<p>Start throwing your service locator everywhere, you&#39;re bound to have a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chr4is</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-730</link>
		<dc:creator>Chr4is</dc:creator>
		<pubDate>Wed, 31 Dec 2008 03:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-730</guid>
		<description>I&#039;m with Mike.&lt;br&gt;&lt;br&gt;For example:&lt;br&gt;&lt;br&gt;In a simple MVC app. I have my CustomControllerFactory locate my controllers. My controllers have constructor dependencies on some Services. My Services have dependencies on infrastructure objects (repository, etc...).&lt;br&gt;&lt;br&gt;The only place my app has a dependency on the container is in the CustomControllerFactory. The container is totally transparent.&lt;br&gt;&lt;br&gt;Start throwing your service locator everywhere, you&#039;re bound to have a problem.</description>
		<content:encoded><![CDATA[<p>I&#39;m with Mike.</p>
<p>For example:</p>
<p>In a simple MVC app. I have my CustomControllerFactory locate my controllers. My controllers have constructor dependencies on some Services. My Services have dependencies on infrastructure objects (repository, etc&#8230;).</p>
<p>The only place my app has a dependency on the container is in the CustomControllerFactory. The container is totally transparent.</p>
<p>Start throwing your service locator everywhere, you&#39;re bound to have a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-601</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Tue, 02 Sep 2008 21:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-601</guid>
		<description>Starting to get well into &#039;service locator&#039; territory here - there&#039;s a lot of discussion out there about the relative merits of each.</description>
		<content:encoded><![CDATA[<p>Starting to get well into &#39;service locator&#39; territory here &#8211; there&#39;s a lot of discussion out there about the relative merits of each.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Byrd</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-600</link>
		<dc:creator>Lee Byrd</dc:creator>
		<pubDate>Tue, 02 Sep 2008 18:24:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-600</guid>
		<description>Mike,&lt;br&gt;You wrote, &quot;I&#039;ve got applications that leverage an IoC container but the only place where the IoC container is referenced is on application startup.&quot;.&lt;br&gt;Can you explain how you accomplish this?&lt;br&gt;Thanks!&lt;br&gt;Lee</description>
		<content:encoded><![CDATA[<p>Mike,<br />You wrote, &#8220;I&#39;ve got applications that leverage an IoC container but the only place where the IoC container is referenced is on application startup.&#8221;.<br />Can you explain how you accomplish this?<br />Thanks!<br />Lee</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Hadlow</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-598</link>
		<dc:creator>Mike Hadlow</dc:creator>
		<pubDate>Tue, 02 Sep 2008 14:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-598</guid>
		<description>I don&#039;t like your property implementation at all. You now have an explicit dependency on the IoC container. Remember IoC is 90% about the IoC/DI pattern and only 10% about the mechanics of how your IoC container works. I&#039;ve got applications that leverage an IoC container but the only place where the IoC container is referenced is on application startup. I think constructor injection makes perfect sense, rather that polluting a service implementation it&#039;s making explicit its dependencies.</description>
		<content:encoded><![CDATA[<p>I don&#39;t like your property implementation at all. You now have an explicit dependency on the IoC container. Remember IoC is 90% about the IoC/DI pattern and only 10% about the mechanics of how your IoC container works. I&#39;ve got applications that leverage an IoC container but the only place where the IoC container is referenced is on application startup. I think constructor injection makes perfect sense, rather that polluting a service implementation it&#39;s making explicit its dependencies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ASP.NET MVC Archived Blog Posts, Page 1</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-592</link>
		<dc:creator>ASP.NET MVC Archived Blog Posts, Page 1</dc:creator>
		<pubDate>Mon, 01 Sep 2008 18:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-592</guid>
		<description>[...] to VoteIs this Better than Constructor Injection? (8/29/2008)Friday, August 29, 2008 from www.emadibrahim.comSo after I finished my post on property injection I [...]</description>
		<content:encoded><![CDATA[<p>[...] to VoteIs this Better than Constructor Injection? (8/29/2008)Friday, August 29, 2008 from <a href="http://www.emadibrahim.comSo" rel="nofollow">http://www.emadibrahim.comSo</a> after I finished my post on property injection I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eibrahim</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-593</link>
		<dc:creator>eibrahim</dc:creator>
		<pubDate>Mon, 01 Sep 2008 17:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-593</guid>
		<description>Ok that makes perfect sense and was sort of what I was thinking but you expressed it much better.&lt;br&gt;&lt;br&gt;I guess if you are writing a framework or code that will be used by others then it makes sens to go with constructor injection because it is explicit what interfaces are the class dependent.&lt;br&gt;&lt;br&gt;If I used a property that automatically creates the interface from IoC container i.e. Kernel.Get...., it will work just the same but then the consumer of that class doesn&#039;t know that.  He doesn&#039;t know which interfaces need to be configured in his IoC container configureation and so on...&lt;br&gt;&lt;br&gt;What if we can configure a class like this:&lt;br&gt;&lt;br&gt;[Inject(IService1, IService2, IService3)]&lt;br&gt;class MyClass&lt;br&gt;&lt;br&gt;This way, I don&#039;t have to &quot;pollute&quot; my constructor and it is still somewhat discoverable and predictable.  What do you think?</description>
		<content:encoded><![CDATA[<p>Ok that makes perfect sense and was sort of what I was thinking but you expressed it much better.</p>
<p>I guess if you are writing a framework or code that will be used by others then it makes sens to go with constructor injection because it is explicit what interfaces are the class dependent.</p>
<p>If I used a property that automatically creates the interface from IoC container i.e. Kernel.Get&#8230;., it will work just the same but then the consumer of that class doesn&#39;t know that.  He doesn&#39;t know which interfaces need to be configured in his IoC container configureation and so on&#8230;</p>
<p>What if we can configure a class like this:</p>
<p>[Inject(IService1, IService2, IService3)]<br />class MyClass</p>
<p>This way, I don&#39;t have to &#8220;pollute&#8221; my constructor and it is still somewhat discoverable and predictable.  What do you think?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blumhardt</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-591</link>
		<dc:creator>Nicholas Blumhardt</dc:creator>
		<pubDate>Sat, 30 Aug 2008 21:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-591</guid>
		<description>The benefit that ctor injection brings is more about predictability than discoverability.&lt;br&gt;&lt;br&gt;It isn&#039;t so obvious when you&#039;re in &#039;author&#039; mode, because at that point you&#039;re intimately familiar with the class&#039;s internals and don&#039;t find any of its interactions with the rest of the system &#039;surprising&#039;.&lt;br&gt;&lt;br&gt;As a user or maintainer of a class, however, you need to be aware of both the provided interfaces, and the required interfaces *equally*. Otherwise, you can have a very hard time when trying to determine exactly how methods called on that class will affect the rest of the application.&lt;br&gt;&lt;br&gt;Provided interfaces -&gt; interface implementations&lt;br&gt;Required interfaces -&gt; constructor parameters&lt;br&gt;&lt;br&gt;The second isn&#039;t necessarily any less important than the first.&lt;br&gt;&lt;br&gt;(Properties can&#039;t be used to emulate the same role, as it is impossible to determine from a property declaration whether the property represents a required interface or just exposes functionality provided by an aggregated component.)&lt;br&gt;&lt;br&gt;Hope this helps!&lt;br&gt;&lt;br&gt;Nick</description>
		<content:encoded><![CDATA[<p>The benefit that ctor injection brings is more about predictability than discoverability.</p>
<p>It isn&#39;t so obvious when you&#39;re in &#39;author&#39; mode, because at that point you&#39;re intimately familiar with the class&#39;s internals and don&#39;t find any of its interactions with the rest of the system &#39;surprising&#39;.</p>
<p>As a user or maintainer of a class, however, you need to be aware of both the provided interfaces, and the required interfaces *equally*. Otherwise, you can have a very hard time when trying to determine exactly how methods called on that class will affect the rest of the application.</p>
<p>Provided interfaces -&gt; interface implementations<br />Required interfaces -&gt; constructor parameters</p>
<p>The second isn&#39;t necessarily any less important than the first.</p>
<p>(Properties can&#39;t be used to emulate the same role, as it is impossible to determine from a property declaration whether the property represents a required interface or just exposes functionality provided by an aggregated component.)</p>
<p>Hope this helps!</p>
<p>Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TroyGoode</title>
		<link>http://www.emadibrahim.com/2008/08/29/is-this-better-than-constructor-injection/comment-page-1/#comment-588</link>
		<dc:creator>TroyGoode</dc:creator>
		<pubDate>Fri, 29 Aug 2008 22:23:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/08/28/is-this-better-than-constructor-injection/#comment-588</guid>
		<description>I&#039;m not sold on constructor injection either. It seems like the biggest argument for it is discoverability, but I just kind of feel like it dirties up my classes for some reason. For the same reason, I&#039;ve been enjoying Autofac&#039;s support for property injection without having to use any [Inject]-style attributes.</description>
		<content:encoded><![CDATA[<p>I&#39;m not sold on constructor injection either. It seems like the biggest argument for it is discoverability, but I just kind of feel like it dirties up my classes for some reason. For the same reason, I&#39;ve been enjoying Autofac&#39;s support for property injection without having to use any [Inject]-style attributes.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->