Contents
What is DDD rule?
domain-driven-design rule-engine ddd-repositories ddd-service. Let’s say If I have an application which let’s user create business rules to be applied on a domain entity. A rule can be a combination of a condition and multiple actions where if condition evaluates to true then corresponding actions are executed.
What is business rule validation?
In short; a validation rule determines basic validity; “is this a valid email address?” A business rule determines what to do with the valid data; “can I set the user’s confirmation email to the submitted value?” Business rules can migrate into validation logic; but typically, validation is not done by the business …
How are validation rules thought of in DDD?
In DDD, validation rules can be thought as invariants. The main responsibility of an aggregate is to enforce invariants across state changes for all the entities within that aggregate. Domain entities should always be valid entities.
Why do we need an ID for an aggregate root?
An Aggregate Root is an Entity and will therefore have an Id. Aggregates should have little or no dependencies on outside services. Imagine how much simpler a class is to design and reason about if it is purely doing it’s thing (i.e. Single Responsibility). No extra clutter of persistence or similar distractions.
Which is an entity in an aggregate root?
The job of enforcing the invariants within a bounded context is that of the Aggregate Root which is also an Entity. Entity: An entity is an object that differs by ID. Take for example, a telephone company. Within that context, a ‘line’ identified by a telephone number would be an entity. The context is important.
How does an aggregate root work in CQRS?
If you are new to CQRS you may want to see where an Aggregate Root fits into a typcial CQRS architecture. You can do that here. The job of an Aggregate Root is to control and encapsulate access to it’s members in such a way as to protect it’s invariants.