Validating Object Compoisitions
Michael Vodep <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <5A039D2914578A4FA83C900B4DBCD5952B0165FD@DB3PRD0310MB392.eurprd03.prod.outlook.com> |
Hi I try to apply DDD to my current private project. Let's assume the domain is something with banks and I have 2 Aggregates - they are responsible for their consistency inside the aggregate. But how about business rules which have to take all 2 Aggregates into account? E.g. Aggregates are "Person" and "Account" and the business rule says "Persons which are older than 25 and today is Tuesday, not more than -20$ of deposit are allowed". In my opinion putting this in a service is not a good idea, because due a software fault some caller could bypass the service and could call "Account.Deposit" directly. So doing the business rule validation in "Account.Deposit" makes sense (in my opinion). If the amount of rules increases, I would put it in a separate "Business Rule" assembly. In the book "Implementing Domain Driven design" I found it on page 215. My questions: * The approach there is to use a Domain Service. Is this not dangerous in case of software faults / bypassing? * Has anybody some good design advices for business rules? I found the "Specification Pattern" - but is there some theory for "Conflicting Rules" or "First match" vs. "All match"? Thanks BR Michael ------------------------------------