Skip to content

Step 11 Aggregate command application.

cdmdotnet edited this page Aug 11, 2015 · 1 revision

Aggregate command application.

The hardest concept for people to grasp is the notion that evaluating business logic means you DO NOT modify state. State changes are made when you apply the event to the aggregate. At the same time, business logic CANNOT exist in the method that applies the event nor in event handlers. In most cases (huge generalisation here) this means no switch or if statements... as that denotes business logic.

The reason state changes are only made when the event is applied to the aggregate, not when the command is handled by the aggregate, is so event re-hydration can occur. If state changes where made when you apply the command, then you wouldn't be able to re-hydrate the aggregate using events.

In some cases, especially with CRUD based systems, this means your command handler will have one line of code... raising the event that the command was handled.

Clone this wiki locally