<?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: Don&#8217;t Trust Fake IDs</title>
	<atom:link href="http://fragmental.tw/2009/10/12/dont-trust-fake-ids/feed/" rel="self" type="application/rss+xml" />
	<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/</link>
	<description>Repeat after me: Data is code, code is data.</description>
	<pubDate>Fri, 10 Sep 2010 18:41:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Nevermind Domain-Driven Design at Fragmental.tw</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-2208</link>
		<dc:creator>Nevermind Domain-Driven Design at Fragmental.tw</dc:creator>
		<pubDate>Mon, 22 Mar 2010 12:36:56 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-2208</guid>
		<description>[...] that I do with my teams. I will try to never use the words entity or value object but I will explain the different types of identity and lifecycle objects have. I will not say that we have a Repository of Users but I will model with them some class that [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] that I do with my teams. I will try to never use the words entity or value object but I will explain the different types of identity and lifecycle objects have. I will not say that we have a Repository of Users but I will model with them some class that [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Yankowsky</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-1994</link>
		<dc:creator>Daniel Yankowsky</dc:creator>
		<pubDate>Fri, 06 Nov 2009 00:08:15 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-1994</guid>
		<description>And in my comment, when I said "OCP", I meant "DIP". Don't ask what I was thinking.</description>
		<content:encoded><![CDATA[<p>And in my comment, when I said &#8220;OCP&#8221;, I meant &#8220;DIP&#8221;. Don&#8217;t ask what I was thinking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Yankowsky</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-1993</link>
		<dc:creator>Daniel Yankowsky</dc:creator>
		<pubDate>Thu, 05 Nov 2009 05:51:38 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-1993</guid>
		<description>Martin,

You raise a good discussion point. However, I agree with the other commenters. Bob Martin, in his Dependency Inversion Principle, says:

A. High level modules should not depend upon low level modules. Both should depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions.

The scenario described by Shoes is a violation of B. (Much discussion of the OCP deals specifically with abstract interfaces and implementations, but I think it is appropriate to whole systems as well). It is desirable to write your business logic with as little knowledge of the underlying details as possible. I'm not saying that anybody can perfectly do this, only that it is the aim we should all have.

Often, the constraints of a system are clearly expressed. For example, you know that a hash map has unique keys, because the documentation says so. But often, the unknowns are not expressed. When you insert a new item, will hashCode be called on all existing keys? Will it be called on only some keys? How may times will it be called per key? Do you care? These details are unspecified.

Certainly, we depend on the fact that HashMap uses unique keys. We probably wanted that behavior. We depend on the fact that Hibernate performs database access on our behalf. Again, we probably wanted that behavior. Should we depend on the fact that Hibernate's concept of identity depends on the current Hibernate Session? This is not behavior that I asked for, so it's better to pretend that was not guaranteed. If we assume nothing about the returned identity, then our code will be better able to adapt to future change (which is Shoes' point).

I'm not trying to pick on you. Again, I think you raise a good point. It is a trap to over analyze and perfect the abstract architecture of a system. But the opposite, to put off as much architecture as we possibly can, just makes tomorrow's work more difficult.</description>
		<content:encoded><![CDATA[<p>Martin,</p>
<p>You raise a good discussion point. However, I agree with the other commenters. Bob Martin, in his Dependency Inversion Principle, says:</p>
<p>A. High level modules should not depend upon low level modules. Both should depend upon abstractions.<br />
B. Abstractions should not depend upon details. Details should depend upon abstractions.</p>
<p>The scenario described by Shoes is a violation of B. (Much discussion of the OCP deals specifically with abstract interfaces and implementations, but I think it is appropriate to whole systems as well). It is desirable to write your business logic with as little knowledge of the underlying details as possible. I&#8217;m not saying that anybody can perfectly do this, only that it is the aim we should all have.</p>
<p>Often, the constraints of a system are clearly expressed. For example, you know that a hash map has unique keys, because the documentation says so. But often, the unknowns are not expressed. When you insert a new item, will hashCode be called on all existing keys? Will it be called on only some keys? How may times will it be called per key? Do you care? These details are unspecified.</p>
<p>Certainly, we depend on the fact that HashMap uses unique keys. We probably wanted that behavior. We depend on the fact that Hibernate performs database access on our behalf. Again, we probably wanted that behavior. Should we depend on the fact that Hibernate&#8217;s concept of identity depends on the current Hibernate Session? This is not behavior that I asked for, so it&#8217;s better to pretend that was not guaranteed. If we assume nothing about the returned identity, then our code will be better able to adapt to future change (which is Shoes&#8217; point).</p>
<p>I&#8217;m not trying to pick on you. Again, I think you raise a good point. It is a trap to over analyze and perfect the abstract architecture of a system. But the opposite, to put off as much architecture as we possibly can, just makes tomorrow&#8217;s work more difficult.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcelo Schmidt</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-1939</link>
		<dc:creator>Marcelo Schmidt</dc:creator>
		<pubDate>Thu, 15 Oct 2009 13:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-1939</guid>
		<description>Martin, 
I guess Shoes is not referring to persistence layer actually, but referring to persistence *policy* instead. And I must say that I agree with Shoes. Imagine you're using "==" operators to compare objects  retrieved from database, when your persistence policy (or technology) changes, the assumption that 2 object with equals db ids can be compared with "==" operator might not be applicable anymore, right? What he's saying is that your identity strategy must be independent of ANY other layer or policy. 

Shoes, 
great article. I like to read your posts 'cause you supply a lot of references to my own learning and thinking. 

Best regards,</description>
		<content:encoded><![CDATA[<p>Martin,<br />
I guess Shoes is not referring to persistence layer actually, but referring to persistence *policy* instead. And I must say that I agree with Shoes. Imagine you&#8217;re using &#8220;==&#8221; operators to compare objects  retrieved from database, when your persistence policy (or technology) changes, the assumption that 2 object with equals db ids can be compared with &#8220;==&#8221; operator might not be applicable anymore, right? What he&#8217;s saying is that your identity strategy must be independent of ANY other layer or policy. </p>
<p>Shoes,<br />
great article. I like to read your posts &#8217;cause you supply a lot of references to my own learning and thinking. </p>
<p>Best regards,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcos Eliziario</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-1936</link>
		<dc:creator>Marcos Eliziario</dc:creator>
		<pubDate>Tue, 13 Oct 2009 04:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-1936</guid>
		<description>Martin, 

The less facts we hold as axiomatic, the better we are on anticipating 
changes, and building useful models.

I don't think the analogy you've made is really relevant to this point. After all a Hash Map is a well defined entity. Not allowing duplicate keys is an essential, defining property of this object, as elemental as knowing that there's no such a thing as the smallest real number &#62; 0. 

In other side, Shoes was refering to a behaviour that could be hardly defined as essential, it's an implementation defined behaviour. Having a dependency on this fact is going to make your code fragile as the author has clearly pointed out.</description>
		<content:encoded><![CDATA[<p>Martin, </p>
<p>The less facts we hold as axiomatic, the better we are on anticipating<br />
changes, and building useful models.</p>
<p>I don&#8217;t think the analogy you&#8217;ve made is really relevant to this point. After all a Hash Map is a well defined entity. Not allowing duplicate keys is an essential, defining property of this object, as elemental as knowing that there&#8217;s no such a thing as the smallest real number &gt; 0. </p>
<p>In other side, Shoes was refering to a behaviour that could be hardly defined as essential, it&#8217;s an implementation defined behaviour. Having a dependency on this fact is going to make your code fragile as the author has clearly pointed out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://fragmental.tw/2009/10/12/dont-trust-fake-ids/#comment-1935</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Mon, 12 Oct 2009 23:21:05 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/?p=154#comment-1935</guid>
		<description>[quote] But the real problem hides in the fact that now your Business Layer depends on an implementation detail of the Persistence Layer.[/quote]

Is this really an issue?

People rely on the guarantees made by underlying infrastructure all the time. A hash map guarantees the objects with different codes will not collide and overwrite. We use that, we're happy, we move on.

At some point you need to be pragmatic about which assumptions you accept and which you account for. If you start accounting for everything, you end up in a world of pain and complexity that's worse than if you just lived with the assumption...

I appreciate the point you're trying to make, but don't necessarily accept the scenario you're using to make it... if that makes sense?</description>
		<content:encoded><![CDATA[<p>[quote] But the real problem hides in the fact that now your Business Layer depends on an implementation detail of the Persistence Layer.[/quote]</p>
<p>Is this really an issue?</p>
<p>People rely on the guarantees made by underlying infrastructure all the time. A hash map guarantees the objects with different codes will not collide and overwrite. We use that, we&#8217;re happy, we move on.</p>
<p>At some point you need to be pragmatic about which assumptions you accept and which you account for. If you start accounting for everything, you end up in a world of pain and complexity that&#8217;s worse than if you just lived with the assumption&#8230;</p>
<p>I appreciate the point you&#8217;re trying to make, but don&#8217;t necessarily accept the scenario you&#8217;re using to make it&#8230; if that makes sense?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
