This may be a basic question but I am pretty new to DDD.
I have an domain object that we’ll call Adjustment which can be processed in bulk from the UI. Before we process the Adjustments, we need to validate the date those adjustments will be applied. My problem is with the location of that IsValidDate() method in my domain object.
- Should it be a static method in the Adjustment class?
- Should it be part of an AdjustmentService class?
- Should I create a AdjustmentsGroup domain object to contain a collection of adjustments and which would also implement IsValidDate?
I would tend to think that the 3rd option is the best one but I have a hard time thinking of a domain term for the group of Adjustment objects. Is it ok to “force” a container type domain object for this type of scenario? Is there a common practice to handle this?
Thank you
Edit: IsValidDate actually contains business logic. This is not just a simple date validation method
I would vote for 2) Make it a DomainService. The code to implement it could be in either a DomainServices class, an AdjustmentServices class, or a ValidateAdjustmentService class, depending on what other services are in the domain model, and what makes the most sense from an organizational perspective.
Another option, (if the rules implemented by this service are business rules) is to implement this as a SPECIFICATION. (Check out pages 224 – 240 in DDD)