Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#-DDD: Which layer DTO belong into?

I am a new comer in DDD concepts and I am trying to design a solution structure strictly follow DDD & Prism (WPF). I am stacking at where to create DTO project (Data Transfer Object). As I know, DDD will have 4 general layer:

Presentation

Application

Domain

Infrastructure

So that, would you please tell me which layer for the DTO project belong to?


I have refered at: DDD - which layer DTO should be implemented Some one told that we should implement it at Service layer, but I think It is not make sense, cause of follow DDD concept, we don't have which called Service layer.

Thank you so much,

Regards

like image 949
Khoa DANG TOAN Avatar asked Jan 04 '23 01:01

Khoa DANG TOAN


1 Answers

Generally speaking, the location of the component's code should stay besides the owner of that component. The owner has full control of its components. This idea follows the dependency inversion principle.

So,in your case, who is the owner of the DTO? Who controls the structure and the purpose of that DTO?

Using DDD (in any architecture!) you should, however, take into account that domain code should not depend on infrastructure, application or UI code. So, if you decide to put the DTO class into the application layer then you cannot refer to that DTO from your domain code (i.e. a domain entity or a domain service cannot have any references to the DTO class - no import or use directive or new statements)

like image 200
Constantin Galbenu Avatar answered Jan 17 '23 05:01

Constantin Galbenu