-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State in domain services #52
Comments
It's free of business state. Technical state is fine, and it's typical for a Domain Service to use a Repository. |
Thanks for your response, Vaughn. The terms "business state" and "technical state" are a bit vague to me, and I can't find good resources on them. As far as I can tell they are not covered in the book. We believe ourselves to have a decent understanding of what can and cannot be stored as class properties on the service, e.g. we wouldn't think to store the tenant or product IDs as properties on BusinessPriorityCalculator, so we'll proceed with the assumption that we can trust our judgment rather than a set of clear rules. |
Your assumption is correct. Associating any business-specific data (model objects) with a Domain Service beyond a single operation is the wrong decision. A Repository is technical state to make it convenient to use one or more Aggregates in the business operation. |
Hi,
In the book, it's clearly stated that domain services should be stateless. However, we noticed that BusinessPriorityCalculator (and possibly other services) do store a repository reference.
We can see why this may not be an issue in practice, given that BacklogItemRepository should be a singleton, but we don't know if that's the reason why this exception was made.
What rules of thumb do you use when sidestepping the "services should be stateless" rule? Thanks!
The text was updated successfully, but these errors were encountered: