<?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"
	>
<channel>
	<title>Comments on: Where to put validation logic?</title>
	<atom:link href="http://www.fuzzylizard.com/archives/2006/09/15/792/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuzzylizard.com/archives/2006/09/15/792/</link>
	<description>My thoughts on Agile, Java and Ruby on Rails (mostly)</description>
	<pubDate>Thu, 20 Nov 2008 15:37:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: fuzzylizard</title>
		<link>http://www.fuzzylizard.com/archives/2006/09/15/792/#comment-6869</link>
		<dc:creator>fuzzylizard</dc:creator>
		<pubDate>Sat, 16 Sep 2006 03:15:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/09/15/792/#comment-6869</guid>
		<description>So basically you are saying that the validation behaviour should be placed in the class that most closely represents the object, in this case, the directory or file class? I tend to agree with this. 

However, to raise a similar issue, one I have seen debated elsewhere, if you extend this logic, then shouldn't you put into a persisted object the ability to persist itself? In other words, if I have a Domain Object whose state is persisted to a database, should that domain object no contain the knowledge to retrieve and store its state from/to the database? This would seem like a logic extension of the above argument?

The problem with this, that most people argue, is that you want to abstract the state of an object away from how it is persisted. This allows you to change the persistence mechanism (e.g., flat files instead of a database) without the domain object knowing about the change. I think in my case, a similar argument could be made. 

I just find it tough to figure out when the abstraction is required and when direct knowledge is required (if that makes any sense).</description>
		<content:encoded><![CDATA[<p>So basically you are saying that the validation behaviour should be placed in the class that most closely represents the object, in this case, the directory or file class? I tend to agree with this. </p>
<p>However, to raise a similar issue, one I have seen debated elsewhere, if you extend this logic, then shouldn&#8217;t you put into a persisted object the ability to persist itself? In other words, if I have a Domain Object whose state is persisted to a database, should that domain object no contain the knowledge to retrieve and store its state from/to the database? This would seem like a logic extension of the above argument?</p>
<p>The problem with this, that most people argue, is that you want to abstract the state of an object away from how it is persisted. This allows you to change the persistence mechanism (e.g., flat files instead of a database) without the domain object knowing about the change. I think in my case, a similar argument could be made. </p>
<p>I just find it tough to figure out when the abstraction is required and when direct knowledge is required (if that makes any sense).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keith ray</title>
		<link>http://www.fuzzylizard.com/archives/2006/09/15/792/#comment-6865</link>
		<dc:creator>keith ray</dc:creator>
		<pubDate>Fri, 15 Sep 2006 14:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/09/15/792/#comment-6865</guid>
		<description>Back when I had to write code that was portable to MacOS 9 and Windows, I created "FileSpec" and "DirectorySpec" objects.  These represent a potential entities in the file system - file or directory - but not  necessarily an actual entity in the file system. 

aDirectorySpec.create() or aFileSpec.create()  would create the actual entity if it did not exist.

aDirectorySpec.exists() or aFileSpec.exists() would identify if the entity existed.

These would take a name in the constructor (and directory ID, volume ID, etc., on MacOS 9).  Could throw an exception for an invalid name, (or maybe I had it just drop or substitute characters and truncate to make the name valid. It's been awhile.)</description>
		<content:encoded><![CDATA[<p>Back when I had to write code that was portable to MacOS 9 and Windows, I created &#8220;FileSpec&#8221; and &#8220;DirectorySpec&#8221; objects.  These represent a potential entities in the file system - file or directory - but not  necessarily an actual entity in the file system. </p>
<p>aDirectorySpec.create() or aFileSpec.create()  would create the actual entity if it did not exist.</p>
<p>aDirectorySpec.exists() or aFileSpec.exists() would identify if the entity existed.</p>
<p>These would take a name in the constructor (and directory ID, volume ID, etc., on MacOS 9).  Could throw an exception for an invalid name, (or maybe I had it just drop or substitute characters and truncate to make the name valid. It&#8217;s been awhile.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
