<?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: Using objects or repository interface in constructor</title>
	<atom:link href="http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html</link>
	<description>Productive software development using ASP.NET, C#, Adobe Flex, and other technologies and tools.</description>
	<lastBuildDate>Fri, 12 Mar 2010 14:26:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Weekly Links #11 &#124; GrantPalin.com</title>
		<link>http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html/comment-page-1#comment-619</link>
		<dc:creator>Weekly Links #11 &#124; GrantPalin.com</dc:creator>
		<pubDate>Mon, 28 Jul 2008 15:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html#comment-619</guid>
		<description>[...] Using objects or repository interface in constructor A brief and tidy example of dependency injection. [...]</description>
		<content:encoded><![CDATA[<p>[...] Using objects or repository interface in constructor A brief and tidy example of dependency injection. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beefarino</title>
		<link>http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html/comment-page-1#comment-615</link>
		<dc:creator>beefarino</dc:creator>
		<pubDate>Fri, 25 Jul 2008 14:19:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html#comment-615</guid>
		<description>Nice post, very succinct example of the problem and benefits you get from the extra effort.

I&#039;ve gone back and forth on this one, sometimes preferring the simplicity of an available collection and other times wanting all the benefits you get with a strategy pattern.  

The compromise I find myself using these days is to have ctors that accept the &quot;most minimal&quot; interface required so the class can to its job (IEnumerable in your example), and then ensure that interface is available on the repository, usually via direct implementation but sometimes using an adapter.  I find this doesn&#039;t really add any measurable work, keeps the objects simple, seperated, and testable, and fits extremely well with IoC frameworks.</description>
		<content:encoded><![CDATA[<p>Nice post, very succinct example of the problem and benefits you get from the extra effort.</p>
<p>I&#8217;ve gone back and forth on this one, sometimes preferring the simplicity of an available collection and other times wanting all the benefits you get with a strategy pattern.  </p>
<p>The compromise I find myself using these days is to have ctors that accept the &#8220;most minimal&#8221; interface required so the class can to its job (IEnumerable in your example), and then ensure that interface is available on the repository, usually via direct implementation but sometimes using an adapter.  I find this doesn&#8217;t really add any measurable work, keeps the objects simple, seperated, and testable, and fits extremely well with IoC frameworks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Beech</title>
		<link>http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html/comment-page-1#comment-614</link>
		<dc:creator>Greg Beech</dc:creator>
		<pubDate>Fri, 25 Jul 2008 06:54:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/07/using-objects-or-repository-interface-in-constructor.html#comment-614</guid>
		<description>It seems to me that depending on whether you take a set of values or a repository, you&#039;ll have classes with quite different semantics.

The first example that takes a sequence of holiday dates would be a stateful class that is used to perform multiple calculations on a set of data which requires the data to be consistent between the calculations, and then the instance would be discarded. The second example that takes a repository would be a stateless class that performs a single calculation on a set of data that is retrieved each time.

So which one you choose would depend on whether you need to perform multiple calculations that share a consistent data set. You might even combine both approaches and have a stateless service which retrieves data from the repository and then constructs a stateful class for the duration of the method call using the list of dates, to perform a number of calculations that need consistent data.</description>
		<content:encoded><![CDATA[<p>It seems to me that depending on whether you take a set of values or a repository, you&#8217;ll have classes with quite different semantics.</p>
<p>The first example that takes a sequence of holiday dates would be a stateful class that is used to perform multiple calculations on a set of data which requires the data to be consistent between the calculations, and then the instance would be discarded. The second example that takes a repository would be a stateless class that performs a single calculation on a set of data that is retrieved each time.</p>
<p>So which one you choose would depend on whether you need to perform multiple calculations that share a consistent data set. You might even combine both approaches and have a stateless service which retrieves data from the repository and then constructs a stateful class for the duration of the method call using the list of dates, to perform a number of calculations that need consistent data.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
