DDD – the rule that Entities can’t access Repositories directly

In Domain Driven Design, there seems to be lots of agreement that Entities should not access Repositories directly.

Did this come from Eric Evans Domain Driven Design book, or did it come from elsewhere?

Where are there some good explanations for the reasoning behind it?

edit: To clarify: I’m not talking about the classic OO practice of separating data access off into a separate layer from the business logic – I’m talking about the specific arrangement whereby in DDD, Entities are not supposed to talk to the data access layer at all (i.e. they are not supposed to hold references to Repository objects)

update: I gave the bounty to BacceSR because his answer seemed closest, but I’m still pretty in the dark about this. If its such an important principle, there should be some good articles about it online somewhere, surely?

update: March 2013, the upvotes on the question imply there’s a lot of interest in this, and even though there’s been lots of answers, I still think there’s room for more if people have ideas about this.

13 Answers
13

Leave a Comment