<?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: Repository Trouble</title>
	<atom:link href="http://fragmental.tw/2007/11/29/repositories-misunderstandings/feed/" rel="self" type="application/rss+xml" />
	<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/</link>
	<description>Repeat after me: Data is code, code is data.</description>
	<pubDate>Wed, 08 Sep 2010 10:32:50 +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/2007/11/29/repositories-misunderstandings/#comment-2209</link>
		<dc:creator>Nevermind Domain-Driven Design at Fragmental.tw</dc:creator>
		<pubDate>Mon, 22 Mar 2010 12:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-2209</guid>
		<description>[...] And that is the same kind of thing 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 represents a list of stuff. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] And that is the same kind of thing 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 represents a list of stuff. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Domain-Driven Bolovo, Passando Conhecimento e etc. &#171; Fragmental</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-2143</link>
		<dc:creator>Domain-Driven Bolovo, Passando Conhecimento e etc. &#171; Fragmental</dc:creator>
		<pubDate>Mon, 18 Jan 2010 11:36:53 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-2143</guid>
		<description>[...] http://fragmental.tw/2007/11/29/repositories-misunderstandings/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://fragmental.tw/2007/11/29/repositories-misunderstandings/" rel="nofollow">http://fragmental.tw/2007/11/29/repositories-misunderstandings/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phillip Calçado "Shoes"</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-1368</link>
		<dc:creator>Phillip Calçado "Shoes"</dc:creator>
		<pubDate>Mon, 27 Oct 2008 20:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-1368</guid>
		<description>Hi Albert,

To understand why use 'Repository' instead of 'DAO' you have to understand the core of Domain-Driven Design: the Ubiquitous Language. This is the language used by user and devs to model the system. It has to be simple and with as little noise as possible so the user can understand.

The DAO is a design pattern and one of the most aspects of design patterns are their name. When you say 'UserDAO' you are telling me that this class accesses some persistent storage to retrieve Users. We generally do not have the concept of 'persistence' in the Ubiquitous Language so the Repository abstracts it. The implementation of the Repository will probably use some kind of DAO but the concept that is used in the language is not tied to persistence, it pretends to be just a in-memory collection.</description>
		<content:encoded><![CDATA[<p>Hi Albert,</p>
<p>To understand why use &#8216;Repository&#8217; instead of &#8216;DAO&#8217; you have to understand the core of Domain-Driven Design: the Ubiquitous Language. This is the language used by user and devs to model the system. It has to be simple and with as little noise as possible so the user can understand.</p>
<p>The DAO is a design pattern and one of the most aspects of design patterns are their name. When you say &#8216;UserDAO&#8217; you are telling me that this class accesses some persistent storage to retrieve Users. We generally do not have the concept of &#8216;persistence&#8217; in the Ubiquitous Language so the Repository abstracts it. The implementation of the Repository will probably use some kind of DAO but the concept that is used in the language is not tied to persistence, it pretends to be just a in-memory collection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Albert</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-1337</link>
		<dc:creator>Albert</dc:creator>
		<pubDate>Sat, 18 Oct 2008 09:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-1337</guid>
		<description>I still don't get it.

How would the repository similar to the mentioned PersonDAO look like in code ?

I bet it will be exactly the same except for the name.</description>
		<content:encoded><![CDATA[<p>I still don&#8217;t get it.</p>
<p>How would the repository similar to the mentioned PersonDAO look like in code ?</p>
<p>I bet it will be exactly the same except for the name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Cadenas</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-905</link>
		<dc:creator>Daniel Cadenas</dc:creator>
		<pubDate>Sun, 27 Apr 2008 16:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-905</guid>
		<description>I see the problem of calling a repository by it's implementation one more case of not using intention-revealing interfaces. After all the name of the interfaces is part of the interface, not only it's member functions.

So using the concept of DAO instead of repository is just one more case of using the how instead of the what.

A DAO for example communicates that they retrieve Data, that they Access something and they are related to Objects. But what it really matters to me is to have a place to interact with the set of some concept I use in my domain, that's all. This is valid even if this concepts are magically generated and don't use a database, because we don't care about this at the domain level.</description>
		<content:encoded><![CDATA[<p>I see the problem of calling a repository by it&#8217;s implementation one more case of not using intention-revealing interfaces. After all the name of the interfaces is part of the interface, not only it&#8217;s member functions.</p>
<p>So using the concept of DAO instead of repository is just one more case of using the how instead of the what.</p>
<p>A DAO for example communicates that they retrieve Data, that they Access something and they are related to Objects. But what it really matters to me is to have a place to interact with the set of some concept I use in my domain, that&#8217;s all. This is valid even if this concepts are magically generated and don&#8217;t use a database, because we don&#8217;t care about this at the domain level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael Ponte &#187; Blog Archive &#187; Aproveitando os beans do Spring em suas páginas JSF</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-278</link>
		<dc:creator>Rafael Ponte &#187; Blog Archive &#187; Aproveitando os beans do Spring em suas páginas JSF</dc:creator>
		<pubDate>Mon, 25 Feb 2008 04:28:29 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-278</guid>
		<description>[...] nas páginas JSF, assim poderíamos acessar qualquer bean gerenciado pelo Spring (Service, DAO, Repository, whatever) nas páginas através de JSF EL sem a necessidade de intermediar o acesso à este bean [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] nas páginas JSF, assim poderíamos acessar qualquer bean gerenciado pelo Spring (Service, DAO, Repository, whatever) nas páginas através de JSF EL sem a necessidade de intermediar o acesso à este bean [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phillip Calçado "Shoes"</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-215</link>
		<dc:creator>Phillip Calçado "Shoes"</dc:creator>
		<pubDate>Mon, 28 Jan 2008 13:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-215</guid>
		<description>Hi, Andrew,

You are right: if you do not agree in the concept of a DAO I use it will be impossible to agree with the text :)

There are some different things here. You say a DAO is not aware of a database but is concerned only about persistence. Well, databases (Relational, Flat files, XML, doesn't matter) are how we keep state nowadays so a DAO is probably dealing with databases. Keeping the object-to-data structures mapping into other object than the DAO may be a valid strategy in some cases but &lt;strong&gt;the DAO would still be aware of the fact that there is a database&lt;/strong&gt;.

I don't like much the link you sent, I refer sun.com's page, but it says:

"Use a Data Access Object to abstract and encapsulate all access to the persistent store. The Data Access Object manages the connection with the data source to obtain and store data. "

Even if you don't consider a DAO to be a Data Mapper (what I strongly disagree, they are clearly Data Mappers for me) you still have them as the objects that deal with the persistence, connections and data sources. Well, persistence, connection and datasources are &lt;strong&gt;not&lt;/strong&gt; business concepts, indeed we define a whole layer only for this aspect of a system.  

We need to abstract the fact that objects need to be persisted and retrieved from the domain, it is a technical limitation and not a business concept. That's why we use repositories: to abstract the very technical concept of persisting and retrieving objects from the business layer.

The DAO abstracts the technology used to persist but the Repository abstracts the fact that objects need to be persisted/retrieved at all.

If you have logic that belongs to a Repository (like calling multiple DAOs) if can be worth its own object but if you only use Repositories to provide Dependency Inversion Principle -very common- just making the Repository an interface implemented by a DAO would be sufficient.

Cheers</description>
		<content:encoded><![CDATA[<p>Hi, Andrew,</p>
<p>You are right: if you do not agree in the concept of a DAO I use it will be impossible to agree with the text <img src='http://fragmental.tw/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>There are some different things here. You say a DAO is not aware of a database but is concerned only about persistence. Well, databases (Relational, Flat files, XML, doesn&#8217;t matter) are how we keep state nowadays so a DAO is probably dealing with databases. Keeping the object-to-data structures mapping into other object than the DAO may be a valid strategy in some cases but <strong>the DAO would still be aware of the fact that there is a database</strong>.</p>
<p>I don&#8217;t like much the link you sent, I refer sun.com&#8217;s page, but it says:</p>
<p>&#8220;Use a Data Access Object to abstract and encapsulate all access to the persistent store. The Data Access Object manages the connection with the data source to obtain and store data. &#8221;</p>
<p>Even if you don&#8217;t consider a DAO to be a Data Mapper (what I strongly disagree, they are clearly Data Mappers for me) you still have them as the objects that deal with the persistence, connections and data sources. Well, persistence, connection and datasources are <strong>not</strong> business concepts, indeed we define a whole layer only for this aspect of a system.  </p>
<p>We need to abstract the fact that objects need to be persisted and retrieved from the domain, it is a technical limitation and not a business concept. That&#8217;s why we use repositories: to abstract the very technical concept of persisting and retrieving objects from the business layer.</p>
<p>The DAO abstracts the technology used to persist but the Repository abstracts the fact that objects need to be persisted/retrieved at all.</p>
<p>If you have logic that belongs to a Repository (like calling multiple DAOs) if can be worth its own object but if you only use Repositories to provide Dependency Inversion Principle -very common- just making the Repository an interface implemented by a DAO would be sufficient.</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Swan</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-208</link>
		<dc:creator>Andrew Swan</dc:creator>
		<pubDate>Fri, 25 Jan 2008 04:04:30 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-208</guid>
		<description>Hi Phillip,

Your article didn't ring true with me, and I realise it's because your definition of a DAO (as a Row Mapper) is different to what I've always thought a DAO was (which is much closer to the concept of a Repository).

To illustrate, here's the type of methods I'd expect to see in a Person DAO (i.e. mainly CRUD methods):

public interface PersonDAO {

  // Returns the Person having the given ID
  Person get(int personID) throws PersonNotFoundException;

  // Deletes the Person having the given ID
  void delete(int personID);

  // Returns the people matching the given search criteria
  List getPeople(List);

  // Adds the given Person (must not have an ID)
  void add(Person person);

  // Updates the given Person (must have an ID)
  void update(Person person);

  // etc etc.
}

This interface could be implemented in lots of ways:
- using a simple in-memory List of Person objects
- using hand-written SQL (e.g. JDBC in the Java world)
- using an ORM tool like Hibernate

The point is that the above DAO only concerns itself with domain concepts; there's nothing in there about mapping or even a database. This is what a DAO means; it hides the details of persistence from the rest of the app. See this page about DAOs (the example they use happens to use a database, but that's an optional implementation detail):

http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm

Row mapping might be a technique used internally within some DAO implementations, but that doesn't mean DAOs and RowMappers are equivalent.

Given the above, I'm still none the wiser about the difference between a DAO and a DDD Repository. The only remotely plausible thing I've heard so far is that DAOs are fine-grained, i.e. you have one DAO per domain class (including Value Objects etc), whereas Repositories only exist for the Entities (aggregate roots) in one's domain model. A repository would therefore be implemented by calling a number of related DAOs to assemble the required aggregates.</description>
		<content:encoded><![CDATA[<p>Hi Phillip,</p>
<p>Your article didn&#8217;t ring true with me, and I realise it&#8217;s because your definition of a DAO (as a Row Mapper) is different to what I&#8217;ve always thought a DAO was (which is much closer to the concept of a Repository).</p>
<p>To illustrate, here&#8217;s the type of methods I&#8217;d expect to see in a Person DAO (i.e. mainly CRUD methods):</p>
<p>public interface PersonDAO {</p>
<p>  // Returns the Person having the given ID<br />
  Person get(int personID) throws PersonNotFoundException;</p>
<p>  // Deletes the Person having the given ID<br />
  void delete(int personID);</p>
<p>  // Returns the people matching the given search criteria<br />
  List getPeople(List);</p>
<p>  // Adds the given Person (must not have an ID)<br />
  void add(Person person);</p>
<p>  // Updates the given Person (must have an ID)<br />
  void update(Person person);</p>
<p>  // etc etc.<br />
}</p>
<p>This interface could be implemented in lots of ways:<br />
- using a simple in-memory List of Person objects<br />
- using hand-written SQL (e.g. JDBC in the Java world)<br />
- using an ORM tool like Hibernate</p>
<p>The point is that the above DAO only concerns itself with domain concepts; there&#8217;s nothing in there about mapping or even a database. This is what a DAO means; it hides the details of persistence from the rest of the app. See this page about DAOs (the example they use happens to use a database, but that&#8217;s an optional implementation detail):</p>
<p><a href="http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm" rel="nofollow">http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm</a></p>
<p>Row mapping might be a technique used internally within some DAO implementations, but that doesn&#8217;t mean DAOs and RowMappers are equivalent.</p>
<p>Given the above, I&#8217;m still none the wiser about the difference between a DAO and a DDD Repository. The only remotely plausible thing I&#8217;ve heard so far is that DAOs are fine-grained, i.e. you have one DAO per domain class (including Value Objects etc), whereas Repositories only exist for the Entities (aggregate roots) in one&#8217;s domain model. A repository would therefore be implemented by calling a number of related DAOs to assemble the required aggregates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael Naufal</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-204</link>
		<dc:creator>Rafael Naufal</dc:creator>
		<pubDate>Mon, 21 Jan 2008 15:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-204</guid>
		<description>Thanks Phillip, there's so misunderstanding about the difference between DAO and Repository and your post clarify that.</description>
		<content:encoded><![CDATA[<p>Thanks Phillip, there&#8217;s so misunderstanding about the difference between DAO and Repository and your post clarify that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leandro</title>
		<link>http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-142</link>
		<dc:creator>Leandro</dc:creator>
		<pubDate>Tue, 11 Dec 2007 17:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://fragmental.tw/2007/11/29/repositories-misunderstandings/#comment-142</guid>
		<description>Congratulations.
Finally I (guess) undestood this confunsion.</description>
		<content:encoded><![CDATA[<p>Congratulations.<br />
Finally I (guess) undestood this confunsion.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
