Aggregate Root Design 101 | DDD, Clean Architecture, .NET 6

preview_player
Показать описание

In this video, I briefly go over how to design an aggregate root and implement it in your .NET applications. The aggregate root pattern from Domain-Driven Design can help you design a better model of your domain. An aggregate acts as a consistency boundary and encapsulates one or more entities. Designing a good aggregate takes a lot of skill and practice.

Join my weekly .NET newsletter:

Subscribe for more:

Chapters
0:00 How our Aggregate looks like
1:34 How to implement AggregateRoot
2:18 How to use AggregateRoot
5:15 Next video teaser
Рекомендации по теме
Комментарии
Автор

what if you have huge data like in Post object. I don't think you can init a domain object with that much... looks useless to me when dealing with large chuncks of data. Thoughts?

botyironcastle
Автор

I just failed at coding round about this concept. but thanks anyway

TrungTran-leht
Автор

Let's say, Post is the AggregateRoot and Comments are the children of Post. A post can have thousands of comments. How would you update a comment through the AggregateRoot? Obviously not pulling all the comments into memory just for updating a single comment. I think we should use filtered include for the children.

tanvirarjel
Автор

was waiting for Aggregate Root Design thx so much <3

emiraksoy
Автор

Great video! I have a couple of questions:

1. What if Gathering is having 1000+ Invitations? Is it wise to fetch the entire Aggregate?
2. When dispatching domain events before committing changes to the DB. How do we handle Email/NotificationService correctly if case committing afterwards fails?

marna_li
Автор

Are you offering any coupon for the course?

sfjadi
Автор

So choosing an aggregate is mainly based on responsibility of the class. What you can identify as a single process and you treat those objects as one unit?

kshooter
Автор

Nice one man. It's really cool that someone explains such stuff to the people who are not familiar with this yet. I with there were such videos when I was investigating this topic

zikkrype
Автор

I got the idea to maintain consistency in DDD, but performance is still an issue if I pull all that information from database. Some others folks also pointed that out here.

luisfalcon
Автор

Don't we need to specify parameterless private constructor to let Entity Framework create an object of specific Entity ? But we should pass an Id to the constructor of the base class using your approach. How do you handle that ? Do you use specific Entity within DbContext?

goorn
Автор

Milan first of all love your work <3. Really !
But I have a question. How with this approach devs can handle large amount of collections ?
I mean it is possible event with this example that gathering can have invitations. How to handel such performance trap ?

medzik
Автор

Hi, watching this a bit later :D
Any reason for not using SingleOrDefault on the gathering.Invitations?

lostinsarajevo
Автор

Is it really prohibited to fetch entities that fall under aggregate separately?
I though that this rule applies only to write operations, whereas for read operations you can do whatever you want

vasthestampede
Автор

Thanks Milan for this great series of DDD. Much appreciated your effort!

ransandu
Автор

Thanks for the series. Informative content. I have a small question: Can I just use the aggregate pattern in Clean Architecture without using DDD (no events etc..).

Ahmed-uiwn
Автор

Hi Milan
in the case that we have to return a dto to the client with data of multiples aggregates, how we can do that without doing multiple queries to the db? because we cant retrieve that data in one single query because the aggregates are not related in the properties so we cant include that data

nicolasundiano
Автор

Hi Milan, great video again. I just want to ask about refactoring legacy code with anemic domain model. I want to apply your teachings towards creating rich domain model but some of these concepts about aggregates are quite complicated so I think I need to spend more time practicing. Would it be a good first step to just move domain logic out of the handler method and into the domain model first without aggregate design and such? Thanks!

huynhtriet
Автор

I am trying to learn the aggregate root patterns but it seems hard for now. Can you please list down the tutorial links from beginning to intermediate so that we can follow them? For example in this video I can see u are adding Aggregate but what are value objects, Entity, how did u add them and which tutorial will show these things?

rpiisenh
Автор

I'm a bit confused about how to define aggregates when there's a N:N relationship, imagine we have TaxRegimes and TaxPayerType, you may have a use case to where you create a TaxPayerType with some TaxRegimes, and other use case where you create a TaxRegime with some TaxPayerTypes associated with it. Which one is the aggregate root? TaxRegime or TaxPayer?

alang
Автор

If your only reading data, why is consistency and issue? Surely an aggregate is for only write actions, read actions should be allowed outside the aggregate if that functionality is necessary (I.e. you only care about a small subset of the aggregate data in some scenario)? If I want to list to the user all invitations for whatever reason, surely I shouldn’t have to pull that through the aggregate?

justgame