Тёмный

Domain Modeling with Domain-Driven Design (From Scratch) 

Milan Jovanović
Подписаться 102 тыс.
Просмотров 26 тыс.
50% 1

Опубликовано:

 

27 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 95   
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@Aweklin
@Aweklin 11 месяцев назад
Hi Milan, glad you posted this. Have added something new to my knowledge base. Will ensure I follow through the series. Hope it's going to be in its own playlist 😊 Thanks a million.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Let me make a playlist for this then!
@alexmadnix
@alexmadnix 11 месяцев назад
Thank you. Milan I've been using C# for a long time, but I've rarely utilized unit testing, so it's something I'm still pretty low on, but after taking the course, I've gained a lot of confidence in it.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Have another video on unit testing coming out soon :)
@matheustorresdosreis9508
@matheustorresdosreis9508 11 месяцев назад
Amazing Milan, looking forward to see how to read the values from domain events
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Already have a few videos in the past about this, check them out
@TheBadspeed
@TheBadspeed 11 месяцев назад
Amazing video, can't wait for the next ones!
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
I've got a fun series lined up 😁
@ibrahimhebish7744
@ibrahimhebish7744 11 месяцев назад
You are doing a great job 👍 Milan, Keep it up.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Appreciate it! :)
@nove1398
@nove1398 11 месяцев назад
This is a great approach for the topic. Lots of useful information here, got a few gems from this video
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Glad it was helpful! This will be a fun series of videos :)
@julienlefevre1661
@julienlefevre1661 6 месяцев назад
Very good video with practical example, clear explainations. Thanks!
@MilanJovanovicTech
@MilanJovanovicTech 6 месяцев назад
Glad it was helpful!
@musazulu7013
@musazulu7013 11 месяцев назад
Thanks a lot @MilanJovanovicTech this is awesome can we please have the entire series related to this
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Working on it!
@keithjairam8452
@keithjairam8452 11 месяцев назад
Love your content…keep it up.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Glad you enjoy it!
@chuo129
@chuo129 11 месяцев назад
Dear. Millan, excellent work. Have you considered make a video about multitenancy? Thanks
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Yes, soon
@ilovepandaypoe6056
@ilovepandaypoe6056 9 месяцев назад
What is the advantage of using an abstract instead of interface for the entity class?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
The lines are blurred because you can also define default implementations in interfaces. But abstract classes can have internal state.
@adahadapato
@adahadapato 8 месяцев назад
thank you for putting this together, please how do I use this Entity base class with entities that have keys named differently from Id. say Code, etc
@MilanJovanovicTech
@MilanJovanovicTech 8 месяцев назад
You can configure that with EF
@KrelleTG
@KrelleTG 10 месяцев назад
Hi Milan. How would you raise a domain event for a deletion, like you have with Create?
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Call a "Cancel/Delete" method on the entity and raise a domain event
@KrelleTG
@KrelleTG 10 месяцев назад
@@MilanJovanovicTech But when would you do this? In this case you call it on example.Create(), but you do not necessarirly have a domain entity in delete. Would you call it in a service layer?
@ferventurart
@ferventurart 11 месяцев назад
Which tool is used to do the diagrams?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Excalidraw
@ZubriQue
@ZubriQue 9 месяцев назад
I have just Models from my DB. How to know which of them are Entities, Valueo Objects or Aggregates?
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Reading the DDD book is a good start
@ZubriQue
@ZubriQue 9 месяцев назад
@@MilanJovanovicTech Thank you for the answer! I am half way through it as I figured out what a Value Object is at least.
@richardhaughton9633
@richardhaughton9633 11 месяцев назад
Hi Milan. Please show us how to correctly configure DDD with EF Core. I always have trouble with private setters and constructors
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
This should help: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-IlXnIe6p_Uk.html
@peterblomqvist227
@peterblomqvist227 11 месяцев назад
Thank you for once again a very good and pedagogic video. I like them all. I have a different situation. We have an old, quite large, database. And I want to refactor the systems around it. My approach is to add a database model (classes reflecting the database who are created by scaffolding), in the infrastructure project together with mappings to and from the new domain model I want to build. I know that it's not optimal adding another DTO layer which also adds complexity. But I don't know what else I could do. A mapping from the database (with Fluent API) to the domain model will be quite complicated (because the db model and the domain model will be so different) and I'm not sure if it's possible to do. Do you have an opinion how to implement a (DDD) domain model for an existing database or another approach to my problem? I must also mention that the primary keys are not GUIDs, they are integers and many times identity columns.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Your approach is fine. The cost is added complexity and more code to maintain. But as long as you have a clear mapping from DB model to Domain model (and vice-versa) - you're on the right track.
@peterblomqvist227
@peterblomqvist227 11 месяцев назад
@@MilanJovanovicTech 👍Thank you Milan. That was good to hear from an external person 😊 I'm trying to use Mapperly for the mapping part. But it's hard to use with value objects. I can't get it to work... I haven't seen any video or found any webpage explaining how that is done. I'll continue checking your great videos and get good ideas from you. Thanks again for the job your doing!
@canodev
@canodev 11 месяцев назад
Which tool do you use to create the diagrams?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Excalidraw
@joehernandez3231
@joehernandez3231 11 месяцев назад
Nicely done. Looking forward to more videos related to the activity tracker.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Coming soon!
@Alexander-zt9kz
@Alexander-zt9kz 3 месяца назад
I am new to DDD, modular monoliths, and designing microservices. Are the modules in your monolith the same as what should be it's own microservice? IE, we have an excercise and a workout module, so would we have an excercise and workout microservice if we were to use microservices?
@Alexander-zt9kz
@Alexander-zt9kz 3 месяца назад
Great video btw 😁
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
Module = bounded context (one way to look at it). Which translates very nicely to a microservice.
@fiqrihafzain2820
@fiqrihafzain2820 9 месяцев назад
can domain modeling to do something like this in clean architecture? data class DevByteVideo(val title: String, val description: String, val url: String, val updated: String, val thumbnail: String) { val shortDescription: String get() = description.smartTruncate(200) }
@MilanJovanovicTech
@MilanJovanovicTech 9 месяцев назад
Why not?
@pity7736
@pity7736 11 месяцев назад
Nice video. Thank you! I have a question: is ok to send that domain event just for instantiating the User entity? What should be the case when User entity is creating a object just because a query from UserRepository? You're not creating a User itself, just instantiating the entity. Thanks!
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
It's ok to send that domain event just for instantiating the User entity
@pity7736
@pity7736 11 месяцев назад
@@MilanJovanovicTech But every time? Imagine that you need to send a welcome email to the user when is created in the system. In that case is perfect. But, imagine that you query that user from database to make login, for example, that domain event will be raised too and the welcome email will be sent. In this case is not so good.
@phennexion
@phennexion 11 месяцев назад
Maybe im just too much of a newbie, but why all this added complexity?
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Showcasing DDD
@dputra
@dputra 11 месяцев назад
The point of ddd is in the effort to align software development (technical) with your users' business cases (domain). You are building a bridge between the developers and the users, creating better communication and collaboration. The first step to achieve this is to identify the "domain" of your user business. What is the entities that will be in the business? What can you do with them? It's necessary to use the proper term, according to your users, of your entity classes. Because keeping the domain knowledge is important in DDD, we have to build a whole structure of projects that builds around those entities. DDD shines if you have expert users and many developers with knowledge gap between them.
@phennexion
@phennexion 10 месяцев назад
@@dputra interesting, thanks for that reply. So I'm guessing it's really good for when a company outsources it's development and helps the developers understand what they're trying to do better?
@dputra
@dputra 10 месяцев назад
I gave up with youtube keep deleting my replies 😫
@dputra
@dputra 10 месяцев назад
@@phennexion It's even impossible for the internal IT team to know exactly the business needs. Softwaremill wrote a good article about DDD. Just google it! 😁
@lexuantruong3835
@lexuantruong3835 10 месяцев назад
That looks like an application service rather than a domain service
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Why?
@enciphered7650
@enciphered7650 11 месяцев назад
I find no utility is doing so much work. Hopefully future videos makes it clear the benefits.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
If you don't see any value in DDD, it probably won't make sense
@petewarner1077
@petewarner1077 11 месяцев назад
It is not true when you say "Name cannot be null" for the static factory method on User just because the parameter type is not marked as nullable. The consumer can explicitly call User.Create(null), ignoring any warnings and the intent of the method. This is exactly the scenario where you *do* want a guard clause. Conversely, the nullability of the value parameter of the Name record should *not* be nullable since you have a guard that will throw if the consumer does pass null.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Easily solvable with nullable reference types and some code analyzers
@petewarner1077
@petewarner1077 11 месяцев назад
​@@MilanJovanovicTech Sorry Milan, I didn't understand your reply. Trying to clarify my own comment: In your video, you have a nullable reference type, and guard against it being null. You also have a non-nullable reference type but don't guard against that being null. You state that the Name value passed to the factory method cannot be null - it can. It's not a struct.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
@@petewarner1077 Conceptually, yes - it can be null. But in any normal execution flow it will never be null. And I'm saying you can guard against this with nullable reference types + code analyzers. You can turn "treat warnings as errors" and the build will never pass if you're trying to pass null for a non-nullable value. Does that make sense?
@Athurito
@Athurito 10 месяцев назад
I dont like nested classes xD
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Easy to clean up 😁
@erandafernando94
@erandafernando94 3 месяца назад
fuck im dumb
@MilanJovanovicTech
@MilanJovanovicTech 3 месяца назад
Why do you say that?
@erandafernando94
@erandafernando94 3 месяца назад
@@MilanJovanovicTech quite hard to catch up lol. had to watch few times. but keep them coming! if u can dumb it down a bit, that would great!
@dmytroshchotkin2939
@dmytroshchotkin2939 10 месяцев назад
4:11 I don't get it. You've created a public ctor in which you're accepting a nullable string argument BUT you're immediately throwing an exception if a 'null' is passed. Why did you make the argument nullable then? You need to do it ONLY if 'null' IS a valid value for the parameter. Otherwise you should explicitly declare that you expect non-null value and to throw an exception if you get 'null'.
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Just a guard clause example, gets cleaned up later
@EvekoShadow
@EvekoShadow 4 месяца назад
Would there be any downsides to using Entity and then use a strongly typed Id when extending User : Entity
@MilanJovanovicTech
@MilanJovanovicTech 4 месяца назад
Other than the complexity?
@pavelkobjakov4148
@pavelkobjakov4148 10 месяцев назад
Why in Name record we are use nullable type in constructor? If I want to create an instance of the Name record then i'll expect that i can pass NULL to Name record, because it accept a nullable type and VS studio don't show me, that i wrong, because constructor accept nullable string but in runtime i get exception
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Compile-time and runtime constraints behave differently
@pavelkobjakov4148
@pavelkobjakov4148 10 месяцев назад
@@MilanJovanovicTech do I understand correctly that in this way we lose the possibility of hints from the IDE and get an error (warning) not at the compilation stage, but in runtime? What is the advantage of this approach?
@caseyspaulding
@caseyspaulding 10 месяцев назад
Thanks. This was a great lesson. Keep it up.
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Glad you liked it!
@sesh3219
@sesh3219 11 месяцев назад
Thank u so much. Hyped for the modular monolith series!
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
Hope you enjoy it!
@KrzysztofBarbarski
@KrzysztofBarbarski 11 месяцев назад
Great video, Milan, does You consider making video about how to deploy app into production? This would be great supplementation of your Clean Architecture course. Without any doubt, i would like to see how You deploy your built on docker app into production using for ex. Azure.
@MilanJovanovicTech
@MilanJovanovicTech 11 месяцев назад
That's an awesome suggestion! I have a CI video coming out soon, but I'll work on a deployment one afterwards. In the meantime, there's this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-QP0pi7xe24s.html
@techpc5453
@techpc5453 10 месяцев назад
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
👋
@nickst0ne
@nickst0ne 11 месяцев назад
I love the strongly-typed properties like the user's name in this video. But I have difficulty setting up the persistence of entities for such properties. I know I've seen it done in one of your videos but it requires a full control on the context, which is something I didn't have in one project where it was database-first and the scaffolding was configuring the context. I think the persistence of strongly-typed ids/properties would deserve a video of its own, considering the different ORMs or approaches.
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
I think you should be able to make it work with fluent config in EF Core?
@RiwenX
@RiwenX 8 месяцев назад
This is great. Please consider creating playlists for those of us who are kinda lost
@MilanJovanovicTech
@MilanJovanovicTech 8 месяцев назад
Good suggestion 😅
@RMarjanovic
@RMarjanovic 10 месяцев назад
What are your thoughts on passing primitive types in the static factory methods instead of Value Object types? I find that I'm cluttering and needing to check lots of results in my use cases before I can actually create the entity / aggregate root. Instead I move the logic of creating value objects to the entity and can combine the results using your railway oriented implementation.
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
I like to assume that everything has been checked by the time I hit my domain entities. But I'm totally not against your approach. I can see how it simplifies the use cases, and moves more of the responsibility to the domain.
@RMarjanovic
@RMarjanovic 9 месяцев назад
@@MilanJovanovicTech After using this for a while and testing with a profiler I noticed that for my usecases I recreate the strongly type id value objects a lot by using this approach. Which caused some performance hits. I refactored to use your approach instead.
@pooper8325
@pooper8325 10 месяцев назад
Hi Milan, I really like this video. Can you also do a video when an aggregate user owns an entity and in the infrastructure layer identityuser is used to handle authentication/authorization?
@MilanJovanovicTech
@MilanJovanovicTech 10 месяцев назад
Planning to do it :)
@farazahmed2616
@farazahmed2616 2 месяца назад
@@MilanJovanovicTech Hey did you ever get around to doing that Video? Would love to watch it.
Далее
How To Use Domain-Driven Design In Clean Architecture
30:27
Новая BMW 5 провал за 10 млн! ИЛИ?..
32:07
How to Use Value Objects to Solve Primitive Obsession
13:54
Being Competent With Coding Is More Fun
11:13
Просмотров 78 тыс.
Domain Driven Design: What You Need To Know
8:42
Просмотров 125 тыс.
DDD By Example - Paul Rayner - DDD Europe 2020
54:58
Просмотров 50 тыс.
Domain Modeling Gone Wrong - Part 1
8:21
Просмотров 27 тыс.
Vertical Slice Architecture Project Setup From Scratch
22:43
Новая BMW 5 провал за 10 млн! ИЛИ?..
32:07