Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 1
    would you mind to elaborate the benefits of allowing entities to meet their repositories? That reminds me to Active Record design pattern. Despite it's considered anti-pattern, I have found libs that implement it. So I'm missing the Pros. The cons I think are clear. Commented Aug 20, 2017 at 20:05
  • 1
    @Laiv The critical difference between Active Record and entity being able to access it's repository is that, with Active Record, it is not possible to structurally separate the implementation of repository (eg. the SQL commands) from the entity/record. But having a middle man, like an interface, does make that possible. So for example, unit testing of entities, in isolation from persistence technology, becomes possible. Which is, I think, main complain when using Active records. Commented Aug 20, 2017 at 20:15
  • 1
    ok. From the unit-testing standpoint, your approach is preferable. But what's the point of allowing entities to meet the DAL? Maybe I'm too oldschool or biased by too many years abstracting the model from everything else. Commented Aug 20, 2017 at 20:22
  • @Laiv Can you explain what you mean by DAL? Also, do you think domain should have abstraction of "collection of all existing entities" within itself? If yes, how is this abstraction represented? If not, how would domain express behavior that works on all existing entities? And by all existing entities I mean for example "all current vehicles". Commented Aug 20, 2017 at 20:27
  • Ok, ok. I think I got your point now. Basically you are looking at the repository as the collection of the existing vehicles while I'm still looking at it as a DAO. But still, should a single entity to be aware of everyone else (should a vehicle to have access the collection?) I guess the answer is no, and that's why you suggested the interface segregation, in order to don't force vehicles to be aware of the collection itself. I'm right? Commented Aug 20, 2017 at 20:34