<?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: Why I don&#8217;t put load/save/delete methods on entity objects</title>
	<atom:link href="http://jonkruger.com/blog/2009/11/05/why-i-dont-put-loadsavedelete-methods-in-entity-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonkruger.com/blog/2009/11/05/why-i-dont-put-loadsavedelete-methods-in-entity-objects/</link>
	<description></description>
	<pubDate>Fri, 18 May 2012 01:15:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Lee Meyers</title>
		<link>http://jonkruger.com/blog/2009/11/05/why-i-dont-put-loadsavedelete-methods-in-entity-objects/comment-page-1/#comment-4741</link>
		<dc:creator>Lee Meyers</dc:creator>
		<pubDate>Wed, 11 Nov 2009 15:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://jonkruger.com/blog/?p=368#comment-4741</guid>
		<description>Jon,

What about if you were using dependency injection to pass in an interface that defines the saving and loading methods (e.g. ICustomerData) and your domain object's Save()/Load()/Delete() methods are defined in an abstract class (from which the entity object inherits - sae BaseDomainObject) that uses a delegate (with a signature like SaveMethod(IDomainObject) from the interface passed in to the constructor of the entity object to perform the operation within the appropriate method.

This way the entity object does technically have Save()/Load()/Delete() methods, as they are defined in the abstract class it inherits from, but the inheriting entity object does not contain any of the details of the saving and loading of object and the implementation of the data operations can be changed by passing in another version of ICustomerData, thereby allowing the use of mocking.

I think the approach I have described is similar, but reading your post made me think again about what I am doing which is never a bad thing!</description>
		<content:encoded><![CDATA[<p>Jon,</p>
<p>What about if you were using dependency injection to pass in an interface that defines the saving and loading methods (e.g. ICustomerData) and your domain object&#8217;s Save()/Load()/Delete() methods are defined in an abstract class (from which the entity object inherits - sae BaseDomainObject) that uses a delegate (with a signature like SaveMethod(IDomainObject) from the interface passed in to the constructor of the entity object to perform the operation within the appropriate method.</p>
<p>This way the entity object does technically have Save()/Load()/Delete() methods, as they are defined in the abstract class it inherits from, but the inheriting entity object does not contain any of the details of the saving and loading of object and the implementation of the data operations can be changed by passing in another version of ICustomerData, thereby allowing the use of mocking.</p>
<p>I think the approach I have described is similar, but reading your post made me think again about what I am doing which is never a bad thing!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

