You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- Hmm I know this pattern, its kind of "domain service" right (additional business logic passed to aggregate method)? Are you sure this kind of logic should be handled in domain level? I mean this is "authorization" part which I think should not be implemented in domain logic (according to all sources I read) because it's does not even have impact on domain model consistency (in opposite to some relation between two aggregates for example). Also authorization may change over time (more checks, more rules, different user types etc) and it would be easier to not change domain model in such case?user606521– user6065212021-02-18 09:56:21 +00:00Commented Feb 18, 2021 at 9:56
- I mean very often in the system it's relatively "easy" to define domain logic from business requirements but actual authorization rules might not be well defined in the beginning and may change quite quickly I think? I feel like it would be easier to handle authorization on different layer from domain...user606521– user6065212021-02-18 10:00:04 +00:00Commented Feb 18, 2021 at 10:00
- I agree that general role-based authorization is usually not a domain concern. But as you noticed yourself, this scenario is different, it's conditional. You still have authorization outside of the domain, but this additional validation should be done in the domain imo.Rik D– Rik D2021-02-18 10:29:30 +00:00Commented Feb 18, 2021 at 10:29
- But does anyone do this in real world? It feels wrong to have let's say half of authorization defined in authorization/controller layer and half passed from authorization/controller layer, through application/command layer, into domain layer. Feels that code will be messy - maybe it's better to break some rules here to keep authorization in one place? Are there any cons of my example #3? The only I see is that authorization layer has access to repository and aggregate object but it can be implemented in the way that it has readonly access to aggregate object.user606521– user6065212021-02-18 15:01:53 +00:00Commented Feb 18, 2021 at 15:01
- 1From my viewpoint, your option 3 is leaking domain knowledge. But if you don't consider these rules business rules then by all means do what works for you. The thing with DDD is that it requires a lot of domain knowledge and refining of the model when your knowledge increases. Don't be affraid to try something out and change if it doesn't work.Rik D– Rik D2021-02-18 15:39:03 +00:00Commented Feb 18, 2021 at 15:39
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you