<?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: Entity interface anti-pattern</title>
	<atom:link href="http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Thu, 21 Feb 2013 18:09: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: Kyle Szklenski</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-20</link>
		<dc:creator>Kyle Szklenski</dc:creator>
		<pubDate>Thu, 14 May 2009 13:26:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-20</guid>
		<description>I&#039;ve seen numerous places where an interface was used to provide only properties. It made me sick. I think doing that basically has the interface implying implementation, or what data is allowed to be stored in the implementing classes. What would the difference be if those weren&#039;t properties at all, but were allowed to be data members directly? Sometimes those properties return abstract types, which is better, but it still seems largely pointless to me to have an interface with just properties. Good post.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve seen numerous places where an interface was used to provide only properties. It made me sick. I think doing that basically has the interface implying implementation, or what data is allowed to be stored in the implementing classes. What would the difference be if those weren&#8217;t properties at all, but were allowed to be data members directly? Sometimes those properties return abstract types, which is better, but it still seems largely pointless to me to have an interface with just properties. Good post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Polling</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-19</link>
		<dc:creator>John Polling</dc:creator>
		<pubDate>Mon, 11 May 2009 09:58:48 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-19</guid>
		<description>Having read your article has made me realise I need to be more careful about the behaviours I&#039;m putting into my service layers that should probably be going into my entities.</description>
		<content:encoded><![CDATA[<p>Having read your article has made me realise I need to be more careful about the behaviours I&#8217;m putting into my service layers that should probably be going into my entities.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chrissie1</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-18</link>
		<dc:creator>chrissie1</dc:creator>
		<pubDate>Mon, 11 May 2009 08:55:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-18</guid>
		<description>There is a use for interfaces on domain entities, and I think I heard this of Udi Dahan. When you use the tell don&#039;t ask principle on your entites you won&#039;t have a need for properites but that makes for difficult unittesting. So you can have an interface that only has methods and an implementation that also has properties for unittesting or peristence. Then you just pass the interface around and don&#039;t need to worry about people using the properties. 

So there can be a reason for interfaces on entites, ok they are not bu still 1:1.</description>
		<content:encoded><![CDATA[<p>There is a use for interfaces on domain entities, and I think I heard this of Udi Dahan. When you use the tell don&#8217;t ask principle on your entites you won&#8217;t have a need for properites but that makes for difficult unittesting. So you can have an interface that only has methods and an implementation that also has properties for unittesting or peristence. Then you just pass the interface around and don&#8217;t need to worry about people using the properties. </p>
<p>So there can be a reason for interfaces on entites, ok they are not bu still 1:1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Gregory</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-17</link>
		<dc:creator>James Gregory</dc:creator>
		<pubDate>Mon, 11 May 2009 08:25:04 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-17</guid>
		<description>To those who mentioned the anemic domain, you are of course right; I should have been a little clearer on what I meant by having no behavior.

Entities should have behavior that concerns their own state, and anything directly related to them. Jak&#039;s examples fall into that category. They should not know how to save themselves (unless you&#039;re doing AR), log themselves, query themselves, etc... That&#039;s the kind of behavior I was referring to (albeit not very clearly).

Again, Jak&#039;s examples are exactly what I&#039;m not talking about in this post. Those are a good example of interfaces on entities. They are a subset of behavior, which can be applied to multiple entities; not a single interface per entity.</description>
		<content:encoded><![CDATA[<p>To those who mentioned the anemic domain, you are of course right; I should have been a little clearer on what I meant by having no behavior.</p>
<p>Entities should have behavior that concerns their own state, and anything directly related to them. Jak&#8217;s examples fall into that category. They should not know how to save themselves (unless you&#8217;re doing AR), log themselves, query themselves, etc&#8230; That&#8217;s the kind of behavior I was referring to (albeit not very clearly).</p>
<p>Again, Jak&#8217;s examples are exactly what I&#8217;m not talking about in this post. Those are a good example of interfaces on entities. They are a subset of behavior, which can be applied to multiple entities; not a single interface per entity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jak Charlton</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-16</link>
		<dc:creator>Jak Charlton</dc:creator>
		<pubDate>Mon, 11 May 2009 07:56:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-16</guid>
		<description>An anemic domain is an anti-pattern ....

1-1 interfaces to classes is also an anti pattern ...


The first is the worst of the two

Entities should and must include behaviour - otherwise they are DTOs not entities (in any real usage of the word)

To solve the second anti pattern - interfaces should be use case based around entities, or preferably around aggregate roots (to use the DDD term).

SO instead of 
Customer : ICustomer  

you have
Customer: IUpgradeableToPreferred,  ICanPlaceAnOrder


etc etc  .... which combines ISP, with avoiding the interface anti-pattern, and putting your domain logic on your entities to avoid an anemic model



</description>
		<content:encoded><![CDATA[<p>An anemic domain is an anti-pattern &#8230;.</p>
<p>1-1 interfaces to classes is also an anti pattern &#8230;</p>
<p>The first is the worst of the two</p>
<p>Entities should and must include behaviour &#8211; otherwise they are DTOs not entities (in any real usage of the word)</p>
<p>To solve the second anti pattern &#8211; interfaces should be use case based around entities, or preferably around aggregate roots (to use the DDD term).</p>
<p>SO instead of<br />
Customer : ICustomer  </p>
<p>you have<br />
Customer: IUpgradeableToPreferred,  ICanPlaceAnOrder</p>
<p>etc etc  &#8230;. which combines ISP, with avoiding the interface anti-pattern, and putting your domain logic on your entities to avoid an anemic model</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justice</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-15</link>
		<dc:creator>Justice</dc:creator>
		<pubDate>Mon, 11 May 2009 01:43:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-15</guid>
		<description>Anonymous is right, in the sense that you assume that your domain model entities should have no behavior. But the opposite is true. Your domain model entities should be rich with behavior, and should certainly be tested. However, all non-pure concerns (persistence, logging, etc) should be done outside of the domain model: persistence with an ORM like NHibernate and logging with interceptors. Therefore, there is no need to have your domain model entities be interfaces: your domain model is perfectly testable on its own, as fully concrete and fully implemented behavior-rich classes.</description>
		<content:encoded><![CDATA[<p>Anonymous is right, in the sense that you assume that your domain model entities should have no behavior. But the opposite is true. Your domain model entities should be rich with behavior, and should certainly be tested. However, all non-pure concerns (persistence, logging, etc) should be done outside of the domain model: persistence with an ORM like NHibernate and logging with interceptors. Therefore, there is no need to have your domain model entities be interfaces: your domain model is perfectly testable on its own, as fully concrete and fully implemented behavior-rich classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Germ&#225;n Schuager</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-14</link>
		<dc:creator>Germ&#225;n Schuager</dc:creator>
		<pubDate>Sun, 10 May 2009 22:49:16 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-14</guid>
		<description>Fabio, I can see some uses for something like ICarInfo, but what do you gain with IVehicle or ICar?</description>
		<content:encoded><![CDATA[<p>Fabio, I can see some uses for something like ICarInfo, but what do you gain with IVehicle or ICar?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-13</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 10 May 2009 22:30:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-13</guid>
		<description>&quot;Entities are purely data structures, and as there&#039;s no variance in how you can implement a structure, there&#039;s nothing that can be gained from abstracting it.&quot; Speaking of anti-patterns: http://martinfowler.com/bliki/AnemicDomainModel.html</description>
		<content:encoded><![CDATA[<p>&#8220;Entities are purely data structures, and as there&#8217;s no variance in how you can implement a structure, there&#8217;s nothing that can be gained from abstracting it.&#8221; Speaking of anti-patterns: <a href="http://martinfowler.com/bliki/AnemicDomainModel.html" rel="nofollow">http://martinfowler.com/bliki/AnemicDomainModel.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabio Maulo</title>
		<link>http://lostechies.com/jamesgregory/2009/05/09/entity-interface-anti-pattern/#comment-12</link>
		<dc:creator>Fabio Maulo</dc:creator>
		<pubDate>Sun, 10 May 2009 22:09:41 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2009/05/09/entity-interface-anti-pattern.aspx#comment-12</guid>
		<description>class Vehicle: IVehicle, IVehicleInfo
class Car: Veicle, ICar, ICarInfo
class CarDTO : ICarInfo
....
ShowCars(IEnumerable&lt;ICarInfo&gt; cars)

Which will be the implementation passed to ShowCars method ?
</description>
		<content:encoded><![CDATA[<p>class Vehicle: IVehicle, IVehicleInfo<br />
class Car: Veicle, ICar, ICarInfo<br />
class CarDTO : ICarInfo<br />
&#8230;.<br />
ShowCars(IEnumerable<icarinfo> cars)</p>
<p>Which will be the implementation passed to ShowCars method ?<br />
</icarinfo></p>
]]></content:encoded>
	</item>
</channel>
</rss>
