In DDD one of the key concepts is Repository, which allows you to retrieve Entities (or Aggregate Roots) and then save them back after they are updated.
Let assume that we need to perform some 'bulk' operation with entities, and the number of entities makes it absolutely impossible to retrieve them into memory. I.e. operation can only be performed in the database.
Where is the place for such 'bulk' operation? Should it be a method on repository? Won't it "leak" Repository abstraction with database specific operation? Won't it move business operation from Entity to Repository?
I think it should be a service.
Evans recommends in his book, that when you are in doubt whether to put a method that "smells bad" inside a class because you think that it doesn't belong there, make a ServiceFoo class with the operation inside.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With