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.
Required fields*
- Sorry, I don't get it. With this approach you describe your aggregate mutations with events, for me is perfect. With this approach you restrict the possible mutations in your domain so you have more control of them. For you what is the issue with the second example?Leonardo Mangano– Leonardo Mangano2020-12-11 01:22:46 +00:00Commented Dec 11, 2020 at 1:22
- And this is a question, why you say that accountLocked = true; is an invariant?Leonardo Mangano– Leonardo Mangano2020-12-11 01:26:40 +00:00Commented Dec 11, 2020 at 1:26
- @LeonardoMangano I suppose it isn't an invariant, but rather an effect, which is what lead me to think about it as more closely tied to an Event. To me, there's no inherent problem with the second example. I guess it's more about the driving factors. To me, it's more about the time relationship between the Event being created, and the state change causing that Event. Without having a separate State class, the state would be inside the Aggregate class. When the Aggregate is told to do something, by calling one of its methods, it does something. For me there's a natural tendency for Events to...Zymus– Zymus2020-12-11 01:56:36 +00:00Commented Dec 11, 2020 at 1:56
- ... represent things that already happened. Without a separate State class, it seems weird if we publish the event without making the appropriate changes to the Aggregate, which is why the second example feels so strange. It feels like we're saying something happened (the account was locked) before the aggregate reflects that fact (Event is created before Locked flag is set to true). I may have thought of a way to reconcile this in my head, by determining the "decision point" of an Event. I'll see if I can find a good way to explain it in the question.Zymus– Zymus2020-12-11 02:00:55 +00:00Commented Dec 11, 2020 at 2:00
- I think your last update is very clear, the event happened when you decided to create it based in a command, after some validations and based in some conditionals. After that event was created (happened) you have lot of reactions like changing the aggregate in memory, then in the DB and then publishing the event. I think this is a good way to think about thisLeonardo Mangano– Leonardo Mangano2020-12-11 02:43:18 +00:00Commented Dec 11, 2020 at 2:43
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