RE: Validating aggregate collections: when and whose job is it?
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
Actually... 1. Verifying the rules at instantiation time could also be performed by a dedicated Factory or a Domain Service. This would remove the unwanted dependencies, but is it really a better idea to have some other object create Customers when it feels so natural to have Companies create them? 2. Verifying the rules at persistence time could also be performed by a Domain Service. This would also remove the unwanted dependencies, but it wouldn't be a very clear API and some developers would still be able to make a call to non-validating CustomerRepository.add instead of going through the Domain Service. So are we really better off?