Clean Architecture vs Domain-Driven Design (DDD) - Understand the Difference

  Рет қаралды 46,525

Amichai Mantinband

Amichai Mantinband

Күн бұрын

Пікірлер: 56
@Codewrinkles
@Codewrinkles 9 ай бұрын
This was one of the key points in my latest video too. This common misunderstanding is very widespread and one of the major reasons why people tend to struggle with understanding software architecture in general.
@mateuszmazurczak1268
@mateuszmazurczak1268 5 ай бұрын
Awesome work and material! I've got some feedback on things that may be misleading in the video: The DDD book (that picture you put in the video) does not speak about event-storming or any tooling to do the domain design itself. The layers shouldn't call outwards (as you showed on application layer), they should only call inwards. So that domain can't call application, application can't call presentation... "Business logic" that you mention speaking about the domain layer is a bit cryptic, as it's not only about logic and "business" word is also not on point since what database you choose, how you call your database etc. at the end is also part of the business. There may be a point in your design (especially at the beginning, but depends on the problem you are trying to solve) that indeed it is a detail, but all of that is part of the business. The more important part is that through design you are able to better decide what can be postponed and what needs to be done right now. So the "domain" layer is more about separating what's the language and concepts that stakeholders use (experts, business people, devs..) and separating it from technical decisions and other parts of the codebase. And here we could say that calling a database is separate from that language, although it's part of that business, but it's a part we don't need to exchange. They won't care if we use postgress or datomic and we do a query with that and that syntax, it's not something worth communicating over. Even though it is part of our business as it can affect performance, security of the data and so on. So in short: Clean/Onion/Ports&Adapters/Hexagonal/Layerd Architecture (so many names...) is just a type of software architecture, structuring of the code and its relations that is advised to use with DDD as it helps separate the domain DDD is about bringing all stakeholders (business people, developers, designers, experts...) to talk together and plan the software that is going to be made, which should result in code reflecting better it's intent, reducing misalignment between "business people" requirements and technical teams and enable better cooperation for future (easier applying changes, easier to exchange on topics, more accurate estimations...)
@tanglesites
@tanglesites 9 ай бұрын
I really like these videos because Amichai talks about the more advanced concepts that are not covered anywhere else on the internet. Because in todays market of developers, you are not getting hired with your typical self-taught You-Tube education. Your projects are going to need some complexity to showcase that you are not just some code-monkey, or react-andy. Before these videos I could not map a domain to schema, or had any idea on to create a domain to begin with. I feel like I had that level of professionalism to my projects needed to get noticed by employers. I think the only thing I have not seen on the internet is how domain events are implemented together with something like Mass Transit or RabbitMQ. Excellent explanation of how separation of concerns synergizes with battle tested patterns and architectural principals to produce quality code.
@sinazare7064
@sinazare7064 Ай бұрын
Great Explanation 👏
@kmcdo
@kmcdo 9 ай бұрын
you've been engagement'd! Loving the fresh vods lately - keep 'em coming!
@ransandu
@ransandu 9 ай бұрын
Agreed what you just said. Also, it's required to understand that DDD != CA. I have seen people claim they have done DDD because they have implemented CA. Which is wrong. DDD can be used to model your problem domain but it should not influence CA. A tactical design decision tree can be used to identify business logic patterns and architecture patterns based on the subdomain identified (supporting, generic, and core)
@SumanNath25
@SumanNath25 Ай бұрын
wo wo wo wooo, for the first time I am hearing NOT technical jargon and something that make sense here. Kiss you bro.
@Moosa_Says
@Moosa_Says 9 ай бұрын
it would be really good if you can show an example project.
@amantinband
@amantinband 9 ай бұрын
What specifically would you like to see?
@Moosa_Says
@Moosa_Says 9 ай бұрын
@@amantinband maybe an example project of bank where each module is divided in it's own layer as you explained. where will be the UI, where will go the validations, models, business logic and where will be the db access layer etc..
@amantinband
@amantinband 9 ай бұрын
I did something similar in this video, check it out - kzbin.info/www/bejne/Z4CvhHhsqb1qZ7ssi=k7Xh-tnPnGHWTJz3
@FalcoSparverius
@FalcoSparverius 9 ай бұрын
Good way to start the week, thanks so much!
@danielolajumoke4389
@danielolajumoke4389 9 ай бұрын
God bless your heart Amichai. Struggled with the relationship between both concepts for quite a while now
@maxweinbrown1180
@maxweinbrown1180 3 ай бұрын
"Repositories go into either the application or domain layers" I believe their implementation goes into the infrastructure layer, but their definition (if you're working with interfaces/headers/protocols) belongs to the domain layer. This keeps the domain from being dependent on the infra layer, while still making use of it, often through dependency injection
@nirajchandrajoshi
@nirajchandrajoshi 9 ай бұрын
Great content I found today
@MrJonnis13
@MrJonnis13 9 ай бұрын
Excellent video indeed.
@MehediHasan-xd6rj
@MehediHasan-xd6rj 9 ай бұрын
Many thanks for the video and expecting more :)
@ferventurart
@ferventurart 9 ай бұрын
Hey Amichai thanks for your explanation it is clear!
@knightmarerip711
@knightmarerip711 9 ай бұрын
Really good vid. However, I kinda got confused when you started talking about the Application layer. Why do you have the application layer talking to the Infra layer? I thought the application layer can only communicate with the domain layer.
@santomy4579
@santomy4579 3 ай бұрын
As far as I know application layer orchestrate the communiticatiin between presentation layer, domain and infrastructure. But however I'm confused why he said repositories are written in application layer. Because I thought infrastructure and repositories where the same
@richardhaughton9633
@richardhaughton9633 28 күн бұрын
@@santomy4579 Only interfaces of the repositories will sit in the application Layer e.g. IUserRepository. The infrastructure layer will contain the UserRepository which implements IUserRepository. The application layer is now free of implementation concerns. This is good if One day you change the implementation details but the application core will remain unchanged or when you do unit testing you can easily mock the repository.
@yevvgor
@yevvgor 9 ай бұрын
Thanks! Crystal clear.
@ErikLallemand
@ErikLallemand 9 ай бұрын
Thanks for your videos, Amichai. My question will sound very specific but who knows... In my industry, experts are referring to real-world objects as "manufacturable" and "manufactured". But the current codebase refers to the corresponding entities as "manufacturableMachine" and "manufacturedMachine". Is there any recommendation on using either language in the codebase? The actual spoken terms, or more formal terms? Or if there is any kind of standard regarding this question, is it bothersome that the words used to refer to these entities are adjectives or past participles?
@islamelgaidi1821
@islamelgaidi1821 9 ай бұрын
Thanks for the video
@marrowfreeze
@marrowfreeze 9 ай бұрын
You can’t make me understand. I refuse to
@shedrachelurihu4883
@shedrachelurihu4883 9 ай бұрын
😂you just have to
@unhandledexception1948
@unhandledexception1948 7 ай бұрын
from your courses would u suggest viewing the DDD before the Clean Architecture?
@ylazerson
@ylazerson 9 ай бұрын
Great video - thanks!
@serb1146
@serb1146 9 ай бұрын
May we say that DDD, is when you develop little framework before for the specific application?
@ono48
@ono48 6 ай бұрын
Clear as mud!
@usmanrahat2913
@usmanrahat2913 Ай бұрын
If someone is taking your courses on Dometrain. Which one should be done first. DDD or Clean Architecture. Looking at this video I guess DDD. Can you please confirm? Thank you
@richaaa_.m
@richaaa_.m 9 ай бұрын
hi, is the content of the video included in one of your dometrain courses? thanks!
@amantinband
@amantinband 9 ай бұрын
Hey, I don't have a section that covers specifically the difference between the two (maybe that's a good idea for future courses). I have in depth courses on both CA and DDD so I would like to believe that viewers would know the difference, but maybe a dedicated sub-section is a good idea for the future
@Radictor44
@Radictor44 4 ай бұрын
Really interesting concepts, sometimes it's good to get away from the code and look at the actual concepts.
@evilpapagali
@evilpapagali 9 ай бұрын
I just don't get why Infrastructure arrow is not from application to infrastructure. If Databases are in infrastructure, wouldn't the application be the one who's calling the infrastructure?
@evilpapagali
@evilpapagali 9 ай бұрын
Researching more about the matter, the arrows are not calling process, but dependency. For implementation, Application layer could just call interfaces. Infrastructure implements those interfaces and then actually store and read data from DB.
@AlfredNing
@AlfredNing 9 ай бұрын
Can you issue a video code to realize the use of the warehouse layer and factory?
@thijsvandervegt3377
@thijsvandervegt3377 9 ай бұрын
Hey Amichai, would it be possible to share the figma files/link for the diagrams/designs you've used in your CA-template? That way we could make similar diagrams for our projects, or update the ones you've used.
@amantinband
@amantinband 9 ай бұрын
Answered on GitHub, but will drop the link to the figma communite plugin here as well for anyone coming across this comment: www.figma.com/community/file/1334042945934670571/clean-architecture-project-file-system
@Udodisgustme
@Udodisgustme 8 ай бұрын
From CA i am not sure that domain layer should contain logic, why is it not in application layer? as part of orchestration. In my experience, domain layer mostly contains domain entities, some constants and hmm maybe some exceptions
@RogerValor
@RogerValor 6 ай бұрын
I feel like this is always explained a bit differently, as originally, the domain layer would contain all interfaces and definitions, and the application layer would implement them in the usecases. so strictly speaking the business "code" is in the application, while the domain only describes, but has no logic, however sets the domain language.
@maroquio
@maroquio 5 ай бұрын
Hello, Amichai. Do you have a special discount for a poor public school teacher from Brazil? 😊
@achrefnabil2463
@achrefnabil2463 9 ай бұрын
Can you please bro do a typescript clean architecture DDD course ❤
@Linkario86
@Linkario86 9 ай бұрын
It's the same principles, just using Typescript?
@amantinband
@amantinband 9 ай бұрын
DDD is language agnostic, and the course would be very similar. The Clean Architecture part would be implemented differently, using different libraries and tools, but would also look very similar. Maybe in general I do think it is a good idea to port the courses to other languages as well to help viewers understand the content in their preferred language, but don't think I'll have time for it in the foreseeable future
@steliosch4684
@steliosch4684 2 ай бұрын
But how can you have CA without DDD? it means orchestration, business rules, will all reside in application layer and not domain? domain layer will be just classes with getter and setter? no behavior, no domain services (as business rules and domain logic is not part of domain layer responsibility? but shifted to higher level? in that case application layer? ) and if my above statement is correct, then what i will benefit from not using ddd and put all the effort and or (write all code) to application layer? It seems to me that once you separate these layers (CA) (especially for large applications) and you know what ddd is, i can't think myself not doing ddd. My reply is not about judging if using ddd is better than not doing it, but rather to understand better the differences and if any, the benefits of not using ddd. ( if any) i also realize that i use both. My domain layer contains, (IRepositoies, Entities with behavior (AR), some value objects, and domain services (some of them make use of repository interfaces , some other just accepting ARoots) to perform some operations or return back ARoots . the infrastructure layer which is the implementation of my repositories and or any other technical concerns Application layer that as you very well mention is just orchestrating and call out the domain services , or loading some AR , call some methods and persist back, Not too much logic, and if possible nothing at all in application layer.
@techandstream
@techandstream 9 ай бұрын
thank
@Linkario86
@Linkario86 9 ай бұрын
Hey Amichai, What do you think about the idea of using Clean Architecture for Modules in a Modular Monolith? On a first glimpse it seems like a good idea, especially since the Data Access can often get messy and Data Access across different Modules is made. With one Infrastructure layer, that wouldn't seem so wrong and confusing.
@amantinband
@amantinband 9 ай бұрын
Using CA with modular monoliths is very common. Regrading infra, most solutions create an infra layer per module. Shared resources would be extracted to a common project if needed, but each of the modules would have it's own ifra layer
@Linkario86
@Linkario86 9 ай бұрын
@@amantinband thank you! The common project is a good idea. In fhe data access we have a lot of cases where many Databases are joined together in each modules data access. That's why I was thinking of one Infra
@kqvanity
@kqvanity 5 ай бұрын
3:31 to the core layer rather?
@dave_s_vids
@dave_s_vids 9 ай бұрын
Great video, thanks... Smash the like button... I don't suppose you're a badminton player are you? ;)
@amantinband
@amantinband 9 ай бұрын
Not at all 😂
@dave_s_vids
@dave_s_vids 9 ай бұрын
@@amantinband :D I ask because it's a catchphrase from a badminton channel I watch ;)
@sheilahbeschorner5309
@sheilahbeschorner5309 9 ай бұрын
*PromoSM* 😈
@youtub3ian728
@youtub3ian728 4 күн бұрын
why did you bald your head ?
Domain-Driven Design: The Last Explanation You'll Ever Need
21:05
Software Developer Diaries
Рет қаралды 10 М.
[WEBINAR] Introduction à l’Architecture & la Clean Architecture
1:25:45
theTribe - Tech&Product Studio
Рет қаралды 14 М.
Каха и лужа  #непосредственнокаха
00:15
Motorbike Smashes Into Porsche! 😱
00:15
Caters Clips
Рет қаралды 23 МЛН
How to Customize Date Time Column Field in Filament
1:27
Code With Jayadev
Рет қаралды 2
Clean Architecture IS about Vertical Slicing, actually!
15:24
About Clean Code
Рет қаралды 38 М.
Understand Clean Architecture in 7 Minutes
7:02
Amichai Mantinband
Рет қаралды 117 М.
STOP dogmatic Domain Driven Design
7:18
CodeOpinion
Рет қаралды 135 М.
Как подключить магнитолу?
0:51
KS Customs
Рет қаралды 2,1 МЛН
Это ЛУЧШИЕ Смартфоны 2024 Года. Недорого и Качественно
15:23
Thebox - о технике и гаджетах
Рет қаралды 115 М.
Сделай Красивее свой iPhone или Android
0:58
AndroHack
Рет қаралды 1,1 МЛН
Today's Console Pick 🔥
0:11
Gleb POV
Рет қаралды 879 М.
ИГРОВОЙ ПК от ИЛОНА МАСКА, Распаковка
32:50
😱Складных смартфонов больше не будет
0:46
ÉЖИ АКСЁНОВ
Рет қаралды 223 М.