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.

9
  • Thank you for the input. Could repository actually represent the Domain.ProductCollection I had in mind, considering they are responsible for retrieving objects from the Domain layer? Commented May 17, 2016 at 13:31
  • @DavidPacker I don't really understand what you mean. Because there should be no need to keep all items in memory. The implementation of the "DoesNameExist" method should be (most probably) SQL query on the data store side. Commented May 17, 2016 at 13:35
  • What is mean is, instead of storing the data in a collection in memory, when I want to know all the Product I don't need to get them from Domain.ProductCollection but ask the repository instead, same with asking, whether the Domain.ProductCollection contains a Product with the passed SKU, this time, again, asking the repository instead (this is actually the example), which instead of iterating over the pre-loaded products queries the underlying database. I don't mean to store all Product in memory unless I have to, doing so would be a complete nonsense. Commented May 17, 2016 at 13:42
  • Which leads to another question, should the repository then knew, whether a attribute should be unique? I have always implemented repositories as pretty dumb components, saving what you pass them to save and trying to retrieve data based on the passed conditions and put the decision into services. Commented May 17, 2016 at 13:44
  • 1
    If there's no aggregate involved then there's always the possibility of a race condition and a db unique constraint is almost the only solution in that case. Commented May 21, 2016 at 7:34