<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Domain-Driven Design: The Repository</title>
	<atom:link href="http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/</link>
	<description>Simple is better than complex. Complex is better than complicated. &#124; @fedecarg</description>
	<lastBuildDate>Mon, 08 Mar 2010 06:09:25 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Federico</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-5059</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Sun, 29 Nov 2009 15:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-5059</guid>
		<description>Hi Benjamin,

A good place to ask about DDD is:
http://www.sitepoint.com/forums/forumdisplay.php?f=147

Or, you can always join a discussion group:
http://tech.groups.yahoo.com/group/domaindrivendesign</description>
		<content:encoded><![CDATA[<p>Hi Benjamin,</p>
<p>A good place to ask about DDD is:<br />
<a href="http://www.sitepoint.com/forums/forumdisplay.php?f=147" rel="nofollow">http://www.sitepoint.com/forums/forumdisplay.php?f=147</a></p>
<p>Or, you can always join a discussion group:<br />
<a href="http://tech.groups.yahoo.com/group/domaindrivendesign" rel="nofollow">http://tech.groups.yahoo.com/group/domaindrivendesign</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin D.</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-5014</link>
		<dc:creator>Benjamin D.</dc:creator>
		<pubDate>Fri, 27 Nov 2009 21:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-5014</guid>
		<description>Hi,

Interesting. However i have some questions.

Let say, we have an user which can have photos albums.
We would have an User object with an albums attribute.

Now, we want to add an album to the user albums collection.

How can we do that with this approach ?

Creating the Album object and then invoke a addAlbumToUser(Model_User user, Model_Album album) from the userRepository ?

or invoke directly a addAlbumToUser(Model_User, title) from the userRepository which will create the Album object ?

or simply add behavior to the Model_User class like a method createAlbum() which will create an album object and add it to the user album collection ?

I admit, i have some difficulties to choose a way :D

It seems objects have not so much behavior, but Repository have.

(sorry for my frenchy english)

Thanks,
Cya, Benjamin.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Interesting. However i have some questions.</p>
<p>Let say, we have an user which can have photos albums.<br />
We would have an User object with an albums attribute.</p>
<p>Now, we want to add an album to the user albums collection.</p>
<p>How can we do that with this approach ?</p>
<p>Creating the Album object and then invoke a addAlbumToUser(Model_User user, Model_Album album) from the userRepository ?</p>
<p>or invoke directly a addAlbumToUser(Model_User, title) from the userRepository which will create the Album object ?</p>
<p>or simply add behavior to the Model_User class like a method createAlbum() which will create an album object and add it to the user album collection ?</p>
<p>I admit, i have some difficulties to choose a way :D</p>
<p>It seems objects have not so much behavior, but Repository have.</p>
<p>(sorry for my frenchy english)</p>
<p>Thanks,<br />
Cya, Benjamin.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4491</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Tue, 04 Aug 2009 15:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4491</guid>
		<description>Hi Don,

The class User was only used as an example. Feel free to rename it to whatever you think reflects better your understanding of the domain, or define a new class based on the context within which this model applies :)</description>
		<content:encoded><![CDATA[<p>Hi Don,</p>
<p>The class User was only used as an example. Feel free to rename it to whatever you think reflects better your understanding of the domain, or define a new class based on the context within which this model applies :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4490</link>
		<dc:creator>Don</dc:creator>
		<pubDate>Tue, 04 Aug 2009 11:06:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4490</guid>
		<description>Hi Federico!

&gt; Not really. The repository is also responsible for talking in aggregate roots.

But what does that mean, &quot;talking&quot;?
As the (known) article also, and only, states, it is responsible for persisting the whole AR. But that&#039;s only one opinion and some other DDD gurus like Greg Young, tell us:
[A repo...] provides the domain collection semantics to a set of aggregate root objects.

Also some tend to say that it&#039;s not the responsibility of the repository to persist anything. Because Repos are the abstraction of objects in memory. Therefore they do live always and don&#039;t have to be persisted. In languages like PHP you&#039;d have a problem with that, though.

The main question is:
If domains should be persistence ignorant, why they would need to have a repository that persists anything?

&gt; User is part of the negotiated language the development team uses with the domain experts. 

Really?
In a webpage scenarion, a &quot;User&quot; may be an Admin, a newly registered site visitor, someone who buys something in your shop, a writer of articles, an anonymous visitor.
There is not ONE user, there are many people (or machines) that play some roles in a given context.
The refinement of the UL in the domain is one of the main things we as developers have to pull out of the domain experts knowledge. 
And in fact that&#039;s not your job but the DE&#039;s one. In a new project you don&#039;t know which roles may exist but you ask all the experts what kind of people (and what roles) they have or expect to see in their business.

Before I knew DDD I also had, like so many others coming from a &quot;data-based&quot; background, a giant User class. Playing all roles and having behaviours of every possible context it could play.
But that was before DDD ;-)

&gt; Bounded Context has nothing to do with Repositories

People in different divisions may have a completely different look at things. 

A domain with only one BC has its set of repositories while another app with many BCs may have completely other ones. But both are working with the same data.

BCs are like single applications inside another. Therefore they have other needs and another view at all the things inside a domain. And for retreiving objects needed for one context we need other instruments than for another. 

The accounting BC may want to look for outstanding invoices. Therefore they need a repo like ReceivableAccountsRepository. 

The customer service desk may want to find registered users and their visiting history on the site.
They need a i.e. MemberRepository.

In both cases an Entity like Member could be involved but not always as an AR but as an Entity inside another AR. 

ARs and almost any other &quot;pattern&quot; of DDD are just logical concepts, not structural ones.</description>
		<content:encoded><![CDATA[<p>Hi Federico!</p>
<p>&gt; Not really. The repository is also responsible for talking in aggregate roots.</p>
<p>But what does that mean, &#8220;talking&#8221;?<br />
As the (known) article also, and only, states, it is responsible for persisting the whole AR. But that&#8217;s only one opinion and some other DDD gurus like Greg Young, tell us:<br />
[A repo...] provides the domain collection semantics to a set of aggregate root objects.</p>
<p>Also some tend to say that it&#8217;s not the responsibility of the repository to persist anything. Because Repos are the abstraction of objects in memory. Therefore they do live always and don&#8217;t have to be persisted. In languages like PHP you&#8217;d have a problem with that, though.</p>
<p>The main question is:<br />
If domains should be persistence ignorant, why they would need to have a repository that persists anything?</p>
<p>&gt; User is part of the negotiated language the development team uses with the domain experts. </p>
<p>Really?<br />
In a webpage scenarion, a &#8220;User&#8221; may be an Admin, a newly registered site visitor, someone who buys something in your shop, a writer of articles, an anonymous visitor.<br />
There is not ONE user, there are many people (or machines) that play some roles in a given context.<br />
The refinement of the UL in the domain is one of the main things we as developers have to pull out of the domain experts knowledge.<br />
And in fact that&#8217;s not your job but the DE&#8217;s one. In a new project you don&#8217;t know which roles may exist but you ask all the experts what kind of people (and what roles) they have or expect to see in their business.</p>
<p>Before I knew DDD I also had, like so many others coming from a &#8220;data-based&#8221; background, a giant User class. Playing all roles and having behaviours of every possible context it could play.<br />
But that was before DDD ;-)</p>
<p>&gt; Bounded Context has nothing to do with Repositories</p>
<p>People in different divisions may have a completely different look at things. </p>
<p>A domain with only one BC has its set of repositories while another app with many BCs may have completely other ones. But both are working with the same data.</p>
<p>BCs are like single applications inside another. Therefore they have other needs and another view at all the things inside a domain. And for retreiving objects needed for one context we need other instruments than for another. </p>
<p>The accounting BC may want to look for outstanding invoices. Therefore they need a repo like ReceivableAccountsRepository. </p>
<p>The customer service desk may want to find registered users and their visiting history on the site.<br />
They need a i.e. MemberRepository.</p>
<p>In both cases an Entity like Member could be involved but not always as an AR but as an Entity inside another AR. </p>
<p>ARs and almost any other &#8220;pattern&#8221; of DDD are just logical concepts, not structural ones.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4486</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Fri, 31 Jul 2009 23:43:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4486</guid>
		<description>Hi Don, 

Not really. The repository is also responsible for talking in aggregate roots.

Reference:

http://dddstepbystep.com/wikis/ddd/blogged-the-repository-pattern.aspx

&gt; One time a User isn&#039;t existing yet, but objects that play a role in a given context

User is part of the negotiated language the development team uses with the domain experts. User, in this case, is something that we, developers and domain experts, understand to mean the same thing. It&#039; s my job then to reflect my understanding of the domain using classes, attributes, relationships and collaboration behaviour.

&gt; you should take a look on the concept Bounded Context

Bounded Context has nothing to do with Repositories and the example provided in this post. The team members define the context within which a model applies.

</description>
		<content:encoded><![CDATA[<p>Hi Don, </p>
<p>Not really. The repository is also responsible for talking in aggregate roots.</p>
<p>Reference:</p>
<p><a href="http://dddstepbystep.com/wikis/ddd/blogged-the-repository-pattern.aspx" rel="nofollow">http://dddstepbystep.com/wikis/ddd/blogged-the-repository-pattern.aspx</a></p>
<p>&gt; One time a User isn&#8217;t existing yet, but objects that play a role in a given context</p>
<p>User is part of the negotiated language the development team uses with the domain experts. User, in this case, is something that we, developers and domain experts, understand to mean the same thing. It&#8217; s my job then to reflect my understanding of the domain using classes, attributes, relationships and collaboration behaviour.</p>
<p>&gt; you should take a look on the concept Bounded Context</p>
<p>Bounded Context has nothing to do with Repositories and the example provided in this post. The team members define the context within which a model applies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4485</link>
		<dc:creator>Don</dc:creator>
		<pubDate>Fri, 31 Jul 2009 12:48:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4485</guid>
		<description>Hi!

You write:
A Repository &quot;...Is a collection of aggregate roots&quot;

The most important, if not ONLY responsibility of a Repository: to retreive an AggregateRoot.
Most repositories do need only one method, find().
Almost any other of the often-seen methods are another context or just plain reporting.

Also perhaps you should take a look on the concept Bounded Context in DDD, then you would realize that there is almost never an Entity &quot;User&quot;, but objects that play a role in a given context. One time a User isn&#039;t existing yet, or is a RegisteredMember or a Visitor. And users don&#039;t appear out of nothing, so who calls new User()...?

Cheers!</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>You write:<br />
A Repository &#8220;&#8230;Is a collection of aggregate roots&#8221;</p>
<p>The most important, if not ONLY responsibility of a Repository: to retreive an AggregateRoot.<br />
Most repositories do need only one method, find().<br />
Almost any other of the often-seen methods are another context or just plain reporting.</p>
<p>Also perhaps you should take a look on the concept Bounded Context in DDD, then you would realize that there is almost never an Entity &#8220;User&#8221;, but objects that play a role in a given context. One time a User isn&#8217;t existing yet, or is a RegisteredMember or a Visitor. And users don&#8217;t appear out of nothing, so who calls new User()&#8230;?</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4483</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Wed, 29 Jul 2009 13:51:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4483</guid>
		<description>Yes, that&#039;s the impression I got as well. Thanks for the comment :)</description>
		<content:encoded><![CDATA[<p>Yes, that&#8217;s the impression I got as well. Thanks for the comment :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4482</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Wed, 29 Jul 2009 08:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4482</guid>
		<description>Well yes, I agree with the UserRepository isolating the Domain object from the DAO, but if you exchange the DAOs for Repositories you just trade a database centric domain for a repository centric domain. Ok, that&#039;s a huge advantage already, but your Entities are still not agnostic and they know how to manage themselves (see User::getData) instead of being managed through the Repository. So instead of ActiveRecord, you get ActiveEntity (kind of). I see the benefit of Lazy Loading in User::getData, but you could separate the repository access strategies through AOP or an event driven approach. But then again, Fowler injects the Repository too, so I guess there is no definite approach and it boils down to personal preference. Thanks again.</description>
		<content:encoded><![CDATA[<p>Well yes, I agree with the UserRepository isolating the Domain object from the DAO, but if you exchange the DAOs for Repositories you just trade a database centric domain for a repository centric domain. Ok, that&#8217;s a huge advantage already, but your Entities are still not agnostic and they know how to manage themselves (see User::getData) instead of being managed through the Repository. So instead of ActiveRecord, you get ActiveEntity (kind of). I see the benefit of Lazy Loading in User::getData, but you could separate the repository access strategies through AOP or an event driven approach. But then again, Fowler injects the Repository too, so I guess there is no definite approach and it boils down to personal preference. Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4480</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Tue, 28 Jul 2009 19:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4480</guid>
		<description>To avoid polluting the domain. The UserRepository class isolates the domain object from details of the UserDaoDb class and provides all data access services to the domain model in the language which the domain understands.</description>
		<content:encoded><![CDATA[<p>To avoid polluting the domain. The UserRepository class isolates the domain object from details of the UserDaoDb class and provides all data access services to the domain model in the language which the domain understands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/#comment-4477</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Sun, 26 Jul 2009 15:28:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fedecarg.com/?p=1445#comment-4477</guid>
		<description>Thanks for all these articles on DDD Federico. One question though: why do you inject the repository into the User Entity? Since the Repo is in charge of managing all the Users, the Entities themselves should not need to be aware of the Repo. At least, they dont if I assume you do all access to them through the Repo.</description>
		<content:encoded><![CDATA[<p>Thanks for all these articles on DDD Federico. One question though: why do you inject the repository into the User Entity? Since the Repo is in charge of managing all the Users, the Entities themselves should not need to be aware of the Repo. At least, they dont if I assume you do all access to them through the Repo.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
