3

From legacy to DDD: What are those events anyway?

 3 years ago
source link: https://blog.arkency.com/2016/02/from-legacy-to-ddd-what-are-those-events-anyway/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

From legacy to DDD: What are those events anyway?

In one of my previous posts, I’ve suggested to start with publishing events. It sounds easy in theory, but in practice it’s not always clear what is an event. The problem is even bigger, as the term event is used in different places with different meaning. In here, I’m focusing on explaining events and commands, with their DDD-related meaning.

Events are facts.

They happened. There’s no arguing about it. That’s why we name them in past tense:

UserRegistered
OrganizationAllowedToUseTheApp
OrderConfirmed

If those are only facts, then what is the thing which is the request to make the fact happen?

Enter commands.

Commands are the objects which represent the intention of the outside world (usually users). A command is like a request:

RegisterUser
AllowOrganizationToUseTheApp
ConfirmOrder

It’s like someone saying “Please do it” to our system.

Usually handling commands in the system, causes some new events to be published.

Commands are the input.

Events are the output.

Both commands and events are almost like only data structures. They contain some “params”.

It’s important to note, they’re not responsible for “handling” any action.

For now, just remember:

commands are requests

events are facts


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK