Building off of the starter kit is as easy as ABCDEF:
Aggregate - Your domain's aggregate root (AR) should inherit from Aggregate
Bus - Messaging (sending commands to handlers, applying events, publishing events) is done through the MessageDispatcher.
Commands - A command is an object that contains information from outside the system.
Domain - Non-AR entities and value objects
Events - An event is an object that contains information about what has happened in the system.
Fetch - This is the read model, complete with any event subscribers and denormalizers to create or update the read model's data store.
Guidance on commands and events:
Make your command and event objects public to the outside world.
Commands are how the outside world (e.g.: the user interface) asks your system to do something.
Events contain information about things that have happened in your system. Other systems can subscribe to events to perform actions in response to those events.
Make your read model objects (DTOs & POCOs) public to the outside world.
Make a read model interface that is public to the outside world, but keep the implementation of that interface internal to your assembly.
Keep your domain objects (AR, value types, entities) internal to your assembly. That way, none of your domain logic "leaks" to the outside.
A leaky domain is one where the outside world can directly manipulate or use the domain. It is considered leaky because an expectation can grow that the outside world needs to know something special about how the domain works internally.
Your domain's aggregate root should handle commands and apply events.
The AR should implement IHandleCommand. Handling the command means to validate that the command against the current state of the aggregate root and returning an event with the details of what to do to modify the state of the aggregate. When handling the command, you do not directly modify the aggregate's state.
The AR should implement IApplyEvent. Applying the event means to take the information in the event and modify the state of the aggregate accordingly.
Building off of the starter kit is as easy as ABCDEF:
Aggregate
MessageDispatcher
.Guidance on commands and events:
IHandleCommand
. Handling the command means to validate that the command against the current state of the aggregate root and returning an event with the details of what to do to modify the state of the aggregate. When handling the command, you do not directly modify the aggregate's state.IApplyEvent
. Applying the event means to take the information in the event and modify the state of the aggregate accordingly.