No video

DDD in .NET Apps: Entities and Value Objects - A Comprehensive Guide

  Рет қаралды 8,601

Codewrinkles

Codewrinkles

Күн бұрын

Пікірлер: 38
@user-bx7xi7bu9k
@user-bx7xi7bu9k Жыл бұрын
the best explanation of Value Objects ever found, I will sleep less stupid tonight 🥳 thx a lot
@Codewrinkles
@Codewrinkles Жыл бұрын
I'm soooo glad you find it useful.
@uzayrsyed6293
@uzayrsyed6293 Жыл бұрын
Great video as always! Looking forward for the EF Core video which shows mapping DDD objects like entities and value objects to database
@Fikusiklol
@Fikusiklol Жыл бұрын
Hello there! First of all thanks for the effort! Your override for == operator might throw an Exception if first Entity is null. I would suggest using Equals(obj1, obj2) operator there :)
@TH2theEO
@TH2theEO 7 ай бұрын
Your channel is amazing! 🎉🎉🎉
@Ronaldos267
@Ronaldos267 Жыл бұрын
First of all, I would like to admit that I learnt a lot from your awesome videos and I keep learning as well. I would also like to admit that I am also learning a lot about DDD from your videos. I have a query - in my opinion, in a big eCommerce system, category can also be a separate bounded context, as categories can also be created, updated, deleted, etc. So we can also create it as an aggregate root/entity. Please correct if I am wrong
@Codewrinkles
@Codewrinkles Жыл бұрын
Thank you very much for your nice feedback. Bounded contexts are used in DDD to define areas of coherent business behavior. According to DDD, bouunded contexts are not necessarily what we define as developers. As Developers we need to understand the business and the bounded contexts it is operating upon. In this paradigm, CRUD logic is never considered business logic and therefore I don't think that categories in an eCommerce system would be a dedicated bounded context.
@Ronaldos267
@Ronaldos267 Жыл бұрын
@@Codewrinkles thank you for your prompt reply. It means if a new product belonging to a new category to be added in the system then it would all be persisted through the product aggregate. But suppose we want to show all the categories as well on the GUI. In this case, we will have to go through all the products to just find out the categories in the system because categories an only be accessed through the aggregate root.
@Codewrinkles
@Codewrinkles Жыл бұрын
I think one of the common misconceptions in DDD modeling is to think about our aggregates and entities in terms of database tables. That's from my point of view the wrong way to try to understand DDD. DDD is about modeling behavior. This overlaps with the tendency to think about everyting in terms of CRUD. These two are the main reasons why DDD fails in most of the attempts. In a real eCommer system modeled around DDD (at least in my opinion and following Evans' guidelines), creating a product is a simple CRUD operation that doesn't need to me modeled in a DDD way. It's just regular transaction script. Further, when you have a create product form, you would have just a few fields like Name and description. Then you would go through a stepper to enhance the product with different functionalities. All these steps in the stepper correspond most probably to different bounded contexts. In this process you would have to choose a category. If the category does not exist, you would have a create new category button that just creates a category the CRUD way. If you take a moment to analyze how Amazon for instance is build and also look at the network in your dev tools you'd see that what you mentioned is not a single process. Here's a video from @codeopinion that illustrates this better: kzfaq.info/get/bejne/ZquBdsZysdqdc5c.html
@danielegiovanetti9258
@danielegiovanetti9258 Жыл бұрын
Very useful video. Thanks so much for sharing this topic
@Codewrinkles
@Codewrinkles Жыл бұрын
My pleasure
@Babs42
@Babs42 2 ай бұрын
Don't they technically call the Entity base class and common interfaces "Seedwork" as opposed to a Shared Kernel BC with code and data shared by multiple bounded contexts (it's technically a context mapping type)?
@TreeLuvBurdpu
@TreeLuvBurdpu Жыл бұрын
I'm still stuck on the river. So, when Hericlitus talked about, for instance the Nile River, he was referring to the volume of water that was in the Nile River channel at that moment? Then, a day later he world have to refer to the Nile water volume of that day as "Nile-water volume v1.0.1” or something? That's not what any normal humans mean when they refer to a river, many of which have lasted for tens of millions of years.
@VinuP2023
@VinuP2023 Жыл бұрын
Useful video. Thanks much :)
@Codewrinkles
@Codewrinkles Жыл бұрын
Glad to hear that!
@borisnicolai9736
@borisnicolai9736 Жыл бұрын
Why do create for each bounded context its own solution and not just projects in one solution? Is there any specific reason? Thanks
@Codewrinkles
@Codewrinkles Жыл бұрын
Usually when you do full DDD you would also go for microservice and each bounded context would be a separate microservice. I wanted to make this total separation clear.
@borisnicolai9736
@borisnicolai9736 Жыл бұрын
Thanks for the (fast!!) response
@Tamer_Ali
@Tamer_Ali Жыл бұрын
Hi Mr.Dan, I have a question about saving attachments/Media "Images and files". is it better to create a single table with fields "ID, FileOriginalName, FileNewName, ContentType, Notes,..." and use the ID to the parent tables?
@Codewrinkles
@Codewrinkles Жыл бұрын
That is for sure one option. Another one would be to have for each entity a dedicated table for file information, so you'd have tables like ProfilePhotos, PostPhotos and so on. In my opinion there is no silver bullet solution here. It all depends on how your application is generally working with files, if it uses a lot of files or not so much and so on.
@OlehYevseienko
@OlehYevseienko Жыл бұрын
🎉🎉🎉
@zutafe
@zutafe Жыл бұрын
Wait for your next video
@Codewrinkles
@Codewrinkles Жыл бұрын
Coming in around one week :)
@rpo3ge
@rpo3ge Жыл бұрын
Hi @Codewrinkles, one question around the base valueobject class, in its current setup would the equality be handled correctly on a collection property? The code only does this.property.Equals(another.Property) unsure if Equals would work with collections, so how can you check type check that? Thank you for the great content on the topic.
@Codewrinkles
@Codewrinkles Жыл бұрын
I'm not sure exactly what you are referring to. When it comes to the value object itself, equality is always calculated with reference to the value object itself. Checking two collections for equality is a total different thing and it's implemented differently in each type that implements ICollection.
@Codewrinkles
@Codewrinkles Жыл бұрын
In a real app you'd never check two collections for equality. And if you do, it would use the .NET implementation for that specific collection type. If you create your custom collection class that implements ICollection, you would need to implement a custom equality check on the collection class itself. Doesn't really have anything to do with the concept of value objects.
@rpo3ge
@rpo3ge Жыл бұрын
Thanks for getting back to me. Say Category has a property of type List AvailableCategories or something like that, I was interested if there is a case of having a collection in a value object and how the equality works. As the current base class seems to handle only primitive types in it’s generic configuration. I.e. how would you do .SequenceEqual() Hope I am making sense!
@Codewrinkles
@Codewrinkles Жыл бұрын
you would also yield return elements from the collection. But once again, it totally depends on how you would like to implement equality and what equality means. If you yield return the appropriate items, then equality check will work. It's not a necessity to yield return just properties.
@nurzhanme
@nurzhanme Жыл бұрын
Entity also should be abstract, right? Also you don't need "id" property in Product class
@Codewrinkles
@Codewrinkles Жыл бұрын
Sure, you can make Entity abstract. It's probably even better.
@rpo3ge
@rpo3ge Жыл бұрын
Hi @Codewrinkles, is the video where you talk about how to use EF Core for persisting the discussed Entities and ValueObjects dynamic, I didn't manage to find it. Thank you
@Codewrinkles
@Codewrinkles Жыл бұрын
It's not there yet. I will publish it on Thursday.
@rpo3ge
@rpo3ge Жыл бұрын
@@Codewrinklesno rush, thank you, appreciate the effort!
@semen083
@semen083 Жыл бұрын
Maybe you don't need "id" property in Product class, because it already exist in base class?
@Codewrinkles
@Codewrinkles Жыл бұрын
You are right about that.
@mdsojibhosen3041
@mdsojibhosen3041 Жыл бұрын
Please give me the souce code link
@Codewrinkles
@Codewrinkles Жыл бұрын
Ambassador Members have access to the source code. You'll be able to get it and use it after you become a member.
@mdsojibhosen3041
@mdsojibhosen3041 Жыл бұрын
@@Codewrinkles How to become a ambassador member.I can't find any link!
English or Spanish 🤣
00:16
GL Show
Рет қаралды 8 МЛН
The Giant sleep in the town 👹🛏️🏡
00:24
Construction Site
Рет қаралды 21 МЛН
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 427 М.
I Asked GPT-4 To Refactor My Legacy Codebase
12:39
Nick Chapsas
Рет қаралды 349 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 257 М.
Tame Your Domain Using THIS Powerful Tool!
21:25
Codewrinkles
Рет қаралды 5 М.
Value Objects
8:12
Coding Concepts
Рет қаралды 18 М.
Mastering DDD Aggregate Modeling With THESE 3 Steps
17:26
Codewrinkles
Рет қаралды 10 М.
What is DDD - Eric Evans - DDD Europe 2019
57:06
Domain-Driven Design Europe
Рет қаралды 259 М.
Don't Use AutoMapper in C#! Do THIS Instead!
16:17
Codewrinkles
Рет қаралды 68 М.
English or Spanish 🤣
00:16
GL Show
Рет қаралды 8 МЛН