Event Sourced Aggregate Design: Focus on Business Logic

preview_player
Показать описание
Separating data and behaviors can have a pretty profound impact on your design. It allows you to focus on business logic by having capabilities produce data (Events). Event Sourcing does exactly this by limiting the amount of state you require only to that needed for business logic within an Aggregate.

💥 Join this channel to get access to source code & demos!

🔥 Don't have the JOIN button? Support me on Patreon!

0:00 Intro
1:40 Current State
5:33 Event Sourcing
11:15 Comparison
Рекомендации по теме
Комментарии
Автор

Wouldn't it be better if you use State Design Pattern, so as to avoid the if statements, and since it naturally a state transition, i.e., has behaviour of a state machine?

oghenekarouzezi
Автор

Awesome video. Don't know if you remember, but asked a question some time ago regarding exactly this topic. This video is like pure gold to me, really makes things clear as to how refactor the relations the current entities have within my application.

Bakhtaryan
Автор

First off, your content is easily the most understandable for the range of topics you cover. So thank you for your wisdom.
I understand the logic behind using this for business logic focused around shipment stops and their state. For this specific example, where would the extra data which was taken out from the aggregate root be stored / handled? Would this be considered another projection? or another Aggregate entirely?
I ask so that I may better understand the structure and procedure of performing these types of transitions to another architecture.
I am currently investigating the viability of ES + CQRS in services for re-designing a legacy project which has a monolith database and I have identified the logical domain boundaries for decomposition of the existing schema.
The project involves managing the entities of teams, players, keeping match information and official score for a popular type of televised sports game.
I am looking moving to an events driven architecture which will allow third party consumers to acquire our data significantly easier than it sits currently.

shaunwratten
Автор

Your events are created and applied, but what about persisting and publishing them? I think with Event Sourcing you should not presist projection (state) but set of events and have possibility to build the state again from stored events.

tomekm
Автор

Okay here come for what I have been waiting for thanks Mate.

sujenm
Автор

I'm developing a similar application, but mine is vastly more complex. I have a Shipment Aggregate with multiple legs.

Each leg can then be assigned to a Manifest Aggregate.

In the manifest it can have legs that belong to various different shipment aggregate.

When a all legs in a shipment are complete, the shipment must move to a completed state.

On a manifest all legs must be completed to complete the manifest.

How would you appropiatley manage this invariance. I'm struggling on how to define the references between both without making legs a completely seperate aggregate. Which would make it so i can't manage those invariance inside of shipments and manfiests.

Any insight would be helpful.

micahoz
Автор

Nice video, but where is the stop ID coming from? DDD best practices recommend against referencing aggregate internal IDs, so curious why you took that approach. Also, the reality of transportation is that signals are unreliable, you might miss a depart signal or something. Now all your subsequent operations will fail due to the strict validation.

gordonfreemanq
Автор

Hello again Derek. thanks again for these videos... they are very helpful :)

Quick question.

I saw that in these examples you din't persist any event at all, you simply updated your projection.

In this scenario that you shown, when you then tell your event store to persist that "changed" event? Who is responsible for the raise of this event?

IE: Following your example, suppose I receive an "Arrive Command", so the aggregator would "Arrive" (checking if is possible to arrive, and so on) but who is responsible to raise the "Arrived" event? the domain model or the command handler? If is the model why is not there?

Lelis
Автор

Really clear and concise explanation. Thanks Derek! Btw, any updates on your architecture course?

ignask
Автор

Can you please post something related gRPC

codewithkashif
Автор

Can you please be like a normal developer and use an old t-shirt that you got from a conference that you barely remembered going to?

Автор

Hi my friend 😌
What's your IDE name?

the_biabireza