Chapter 7 - Focus on the behavior

continues from Chapter 6 - The aggregate could cause unnecessary complexity

......

Can we happily live without aggregates?

I think we can!

Since it is difficult to design the right aggregates, I asked myself: can we guarantee consistency in another way? In a more flexible and less constraining way than the aggregate one?

The secret, from my point of view, is to focus on the behavior, not on the model.




We want to go back to the fluidity, the naturalness, and the beauty of storytelling.
Imagine simplifying the system as much as possible, until it is nothing more than a series of actions and reactions. The causal link between them is represented by a decision, taken on the basis of one or more business rules.


This is precisely the atomic element we need, the block that connects a specific trigger to its consequences.

We could compare this chain of actions and reactions to a game of ping pong between a person and the system. On one side, the person, triggered by a certain situation,  is able to retrieve all the information needed to make a decision. 
On the other side, the software component, triggered by a certain situation, should be able to load all information needed to make a decision. Exactly as the person does.


The focus here is on the behavior, not the model.
The decision block exists because the system needs to react to a certain trigger.
It is the behavior that determines the need to have that decision block.

The focus is on the software component that reacts to a trigger. The trigger could be a command, and then the decision block could be called "command handler". The trigger could also be an event, and then the decision block could be called "event handler". It does not really matter, more generally we can call it "message handler".

The important bit here is that the decision block is able to load the model needed to do its job.

At this point, event sourcing comes to our aid, because provides the huge advantage of decoupling the persistence from the model needed for making a decision. 

The story continues to the next chapter

... or watch the full story on youtube

Comments

Popular posts from this blog

Chapter 1 - I am here to kill the aggregate

Chapter 2 - The Aggregate does not fit the storytelling

Chapter 8 - The death of the aggregate