<?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: &#8216;Disappeared&#8217; DAO layers</title>
	<atom:link href="http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/</link>
	<description>programming idiom and methodology</description>
	<lastBuildDate>Sun, 07 Mar 2010 02:56:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: DAO - it&#8217;s not about Layering, it&#8217;s about Abstraction! &#171; brain driven development</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-71</link>
		<dc:creator>DAO - it&#8217;s not about Layering, it&#8217;s about Abstraction! &#171; brain driven development</dc:creator>
		<pubDate>Tue, 17 Feb 2009 00:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-71</guid>
		<description>[...] February 17, 2009 &#8212; Mario Gleichmann   Again there were some interesting debates in the near past, which once again discussed the role of the DAO within enterprise applications, [...]</description>
		<content:encoded><![CDATA[<p>[...] February 17, 2009 &#8212; Mario Gleichmann   Again there were some interesting debates in the near past, which once again discussed the role of the DAO within enterprise applications, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scot Mcphee</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-63</link>
		<dc:creator>Scot Mcphee</dc:creator>
		<pubDate>Mon, 09 Feb 2009 21:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-63</guid>
		<description>Yes it does - to deserialize it. And if you&#039;re using maven, the dependency is brought in transiently.</description>
		<content:encoded><![CDATA[<p>Yes it does &#8211; to deserialize it. And if you&#8217;re using maven, the dependency is brought in transiently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris Menounos</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-61</link>
		<dc:creator>Dimitris Menounos</dc:creator>
		<pubDate>Mon, 09 Feb 2009 15:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-61</guid>
		<description>&quot;Oh, the annotations are in the relevant namespace... So once you put that on a class all its clients have a transient dependency to it.&quot;

Forgive me, I still don&#039;t understand :) For example:

package foo;
public @interface Bar {
  // custom annotation
}

package model;
@foo.Bar
public class Person {
  // model class with annotation
}

public class Test {
    public static void main(String[] args) {
        new model.Person();
    }
}

Test (the client) needs not foo.Bar in order to compile and run.</description>
		<content:encoded><![CDATA[<p>&#8220;Oh, the annotations are in the relevant namespace&#8230; So once you put that on a class all its clients have a transient dependency to it.&#8221;</p>
<p>Forgive me, I still don&#8217;t understand <img src='http://www.crazymcphee.net/x/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  For example:</p>
<p>package foo;<br />
public @interface Bar {<br />
  // custom annotation<br />
}</p>
<p>package model;<br />
@foo.Bar<br />
public class Person {<br />
  // model class with annotation<br />
}</p>
<p>public class Test {<br />
    public static void main(String[] args) {<br />
        new model.Person();<br />
    }<br />
}</p>
<p>Test (the client) needs not foo.Bar in order to compile and run.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scot Mcphee</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-60</link>
		<dc:creator>Scot Mcphee</dc:creator>
		<pubDate>Mon, 09 Feb 2009 13:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-60</guid>
		<description>Mario, that&#039;s an excellent post, I see written over a year ago, and I agree with all the points in it!</description>
		<content:encoded><![CDATA[<p>Mario, that&#8217;s an excellent post, I see written over a year ago, and I agree with all the points in it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scot Mcphee</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-59</link>
		<dc:creator>Scot Mcphee</dc:creator>
		<pubDate>Mon, 09 Feb 2009 13:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-59</guid>
		<description>Oh, the annotations are in the relevant namespace, e.g. the @Entity annotation is javax.persistence.Entity ( see http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html ). So once you put that on a class all its clients have a transient dependency to it.

As I state in the article, I prefer to work (though not always - depends if I&#039;ve got a &#039;clean slate&#039; or not among other things) by modeling the target domain first in a TDD fashion. The main reason is that you can usually actually model (i.e. test then write) a surprising amount of behavior in the system before you even have to consider an actual functioning persistence mechanism!

I guess that&#039;s maybe another reason why I think declaring the-service-does-the-persistence to be the wrong idea - it&#039;s putting the persistence methods ahead of the business problem domain.</description>
		<content:encoded><![CDATA[<p>Oh, the annotations are in the relevant namespace, e.g. the @Entity annotation is javax.persistence.Entity ( see <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html" rel="nofollow">http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html</a> ). So once you put that on a class all its clients have a transient dependency to it.</p>
<p>As I state in the article, I prefer to work (though not always &#8211; depends if I&#8217;ve got a &#8216;clean slate&#8217; or not among other things) by modeling the target domain first in a TDD fashion. The main reason is that you can usually actually model (i.e. test then write) a surprising amount of behavior in the system before you even have to consider an actual functioning persistence mechanism!</p>
<p>I guess that&#8217;s maybe another reason why I think declaring the-service-does-the-persistence to be the wrong idea &#8211; it&#8217;s putting the persistence methods ahead of the business problem domain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Gleichmann</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-58</link>
		<dc:creator>Mario Gleichmann</dc:creator>
		<pubDate>Mon, 09 Feb 2009 13:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-58</guid>
		<description>Good post!

Allthough the debate about DAOs is at least in its third round nowadays, it still seems to riling up a good part of developers minds.

For myself, i posted an answer to Adam&#039;s very first entry on that subject but still wait for an answer ... ;o)

You might want to take a look at

http://gleichmann.wordpress.com/2007/11/22/why-dao-wont-die/

Greetings

Mario</description>
		<content:encoded><![CDATA[<p>Good post!</p>
<p>Allthough the debate about DAOs is at least in its third round nowadays, it still seems to riling up a good part of developers minds.</p>
<p>For myself, i posted an answer to Adam&#8217;s very first entry on that subject but still wait for an answer &#8230; ;o)</p>
<p>You might want to take a look at</p>
<p><a href="http://gleichmann.wordpress.com/2007/11/22/why-dao-wont-die/" rel="nofollow">http://gleichmann.wordpress.com/2007/11/22/why-dao-wont-die/</a></p>
<p>Greetings</p>
<p>Mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris Menounos</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-57</link>
		<dc:creator>Dimitris Menounos</dc:creator>
		<pubDate>Mon, 09 Feb 2009 12:08:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-57</guid>
		<description>I use xml mappings in place of annotations too, but mostly because of preference. I can&#039;t see how using annotations would make the client import javax.persistence stuff though.

For your next point, I haven&#039;t been so far imposed a legacy schema to work on, yet still I think that that is exactly the value ORMs should be providing. The mapping of the database relational data to the actual application model. If a whole another layer of classes, in addition to the metadata, has to fit between the ORM and the model then IMHO something is not very right.

To make myself clear, I don&#039;t say that I always use pure entities in the client. It depends on the use case. For example if I had to display a complex grid of entities along with some of their relations and other computed details, I would probrably use a wrapper object (DTO if you will)..</description>
		<content:encoded><![CDATA[<p>I use xml mappings in place of annotations too, but mostly because of preference. I can&#8217;t see how using annotations would make the client import javax.persistence stuff though.</p>
<p>For your next point, I haven&#8217;t been so far imposed a legacy schema to work on, yet still I think that that is exactly the value ORMs should be providing. The mapping of the database relational data to the actual application model. If a whole another layer of classes, in addition to the metadata, has to fit between the ORM and the model then IMHO something is not very right.</p>
<p>To make myself clear, I don&#8217;t say that I always use pure entities in the client. It depends on the use case. For example if I had to display a complex grid of entities along with some of their relations and other computed details, I would probrably use a wrapper object (DTO if you will)..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scot Mcphee</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-56</link>
		<dc:creator>Scot Mcphee</dc:creator>
		<pubDate>Mon, 09 Feb 2009 09:53:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-56</guid>
		<description>Hello Dimitris

Thanks for your excellent comment.

I think it&#039;s a mistake that any client of a service layer has to also import, for example, org.hibernate.* - javax.persistence is a little bit less pernicious  than hibernate, but only slightly. I really don&#039;t like such persistence artifacts escaping the layers that are directly dealing with them. Why should a Struts action or a Tapestry page class (etc) be concerned about hibernate or any other database semantic? The point of layering is to isolate concerns. So for me, this means, if you want domain classes to also be your persistence model, no annotations (generally speaking). Cfg files I can live with, and in fact, over the past while I have increasingly leaned towards using e.g. .xbm configuration to map the domain classes to the database and have moved very much away from annotations to do it (this is also to do with what I see as the poor readability of the Java 5 extensions).

I also think, that it&#039;s a huge mistake to assume that a domain model will exactly match the most performant or otherwise optimum relational model of the data. There is a fundamental mismatch - sometimes (and sometimes it&#039;s not, in which case I&#039;ll lean to the solution above). Also sometimes, you might have a relational persistence model forced on you by an already-existing database. To just assume, that the model that you can use to describe the functioning of the system (as for example illustrated in my rather twee taxi-ordering example above) is the same one as storage of the data is a big mistake (again, sometimes, not always). I find, as you develop a system, driven by its domain description, you want to be able to rapidly evolve the domain model in ways that may be incompatible with the slower evolution of a database structure and it&#039;s normalised form (or for example, its highly optimised and specialised, relational form - especially if the database is already &#039;legacy&#039; and can&#039;t be changed as easily as the OO domain model).</description>
		<content:encoded><![CDATA[<p>Hello Dimitris</p>
<p>Thanks for your excellent comment.</p>
<p>I think it&#8217;s a mistake that any client of a service layer has to also import, for example, org.hibernate.* &#8211; javax.persistence is a little bit less pernicious  than hibernate, but only slightly. I really don&#8217;t like such persistence artifacts escaping the layers that are directly dealing with them. Why should a Struts action or a Tapestry page class (etc) be concerned about hibernate or any other database semantic? The point of layering is to isolate concerns. So for me, this means, if you want domain classes to also be your persistence model, no annotations (generally speaking). Cfg files I can live with, and in fact, over the past while I have increasingly leaned towards using e.g. .xbm configuration to map the domain classes to the database and have moved very much away from annotations to do it (this is also to do with what I see as the poor readability of the Java 5 extensions).</p>
<p>I also think, that it&#8217;s a huge mistake to assume that a domain model will exactly match the most performant or otherwise optimum relational model of the data. There is a fundamental mismatch &#8211; sometimes (and sometimes it&#8217;s not, in which case I&#8217;ll lean to the solution above). Also sometimes, you might have a relational persistence model forced on you by an already-existing database. To just assume, that the model that you can use to describe the functioning of the system (as for example illustrated in my rather twee taxi-ordering example above) is the same one as storage of the data is a big mistake (again, sometimes, not always). I find, as you develop a system, driven by its domain description, you want to be able to rapidly evolve the domain model in ways that may be incompatible with the slower evolution of a database structure and it&#8217;s normalised form (or for example, its highly optimised and specialised, relational form &#8211; especially if the database is already &#8216;legacy&#8217; and can&#8217;t be changed as easily as the OO domain model).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris Menounos</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-55</link>
		<dc:creator>Dimitris Menounos</dc:creator>
		<pubDate>Mon, 09 Feb 2009 09:04:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-55</guid>
		<description>&quot;I also have a strong prejudice against JPA or hibernate annotated objects ‘escaping’ the persistence layer.&quot;

If that was about DTOs I will have to disagree. I generaly avoid them like the plague and always strive to use my POJO Entities as much as possible.

&quot;I find it disconcerting that the client layer would require a dependency on persistence infrastructure.&quot;

Would you care to elaborate on that? As I said I use entities all the way through the client and have never had such a problem.</description>
		<content:encoded><![CDATA[<p>&#8220;I also have a strong prejudice against JPA or hibernate annotated objects ‘escaping’ the persistence layer.&#8221;</p>
<p>If that was about DTOs I will have to disagree. I generaly avoid them like the plague and always strive to use my POJO Entities as much as possible.</p>
<p>&#8220;I find it disconcerting that the client layer would require a dependency on persistence infrastructure.&#8221;</p>
<p>Would you care to elaborate on that? As I said I use entities all the way through the client and have never had such a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sakuraba</title>
		<link>http://www.crazymcphee.net/x/2009/02/06/disappeared-dao-layers/comment-page-1/#comment-53</link>
		<dc:creator>Sakuraba</dc:creator>
		<pubDate>Sun, 08 Feb 2009 13:29:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=139#comment-53</guid>
		<description>Not having persistence logic abstracted =&gt; Mixing different concerns in one big service =&gt; makes it hard to test the service, because the databse abstraction must be there and cannot be simply mocked away =&gt; as the system grows applying this pattern leads to unmaintainable and untestable messy code that will drive you into unhappiness, kill your productivity and will make the project fail


Search for &quot;Misko Hevery&quot; (a Test Engineer at Google) on Google Video to have your eyes opened. Those videos made me a TDD-guy, because I finally saw what was wrong with my code structuring.

No being able to replace an implementation of a specific concern e.g. by using DI and interface-driven-design, with a &#039;seam&#039;/mock/test-spy is the dead end for testability. This is exactly what happens when you use EntityManager inside your services. Mixing Services with EntityManager-data-access leads to untestable code. No excuse, end of story.</description>
		<content:encoded><![CDATA[<p>Not having persistence logic abstracted =&gt; Mixing different concerns in one big service =&gt; makes it hard to test the service, because the databse abstraction must be there and cannot be simply mocked away =&gt; as the system grows applying this pattern leads to unmaintainable and untestable messy code that will drive you into unhappiness, kill your productivity and will make the project fail</p>
<p>Search for &#8220;Misko Hevery&#8221; (a Test Engineer at Google) on Google Video to have your eyes opened. Those videos made me a TDD-guy, because I finally saw what was wrong with my code structuring.</p>
<p>No being able to replace an implementation of a specific concern e.g. by using DI and interface-driven-design, with a &#8217;seam&#8217;/mock/test-spy is the dead end for testability. This is exactly what happens when you use EntityManager inside your services. Mixing Services with EntityManager-data-access leads to untestable code. No excuse, end of story.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
