Where to put DTO, result objects, etc.?

I have a pretty simple ASP.NET MVC project structure. However, I am struggling to organize a host of classes that are DTOs (data transfer objects), for example. just to encapsulate post data from forms (viewmodels), but not representing complete domain objects or anything else nearby; and then a lot of “result” objects that pass complex resulting information from my service level back to the controller. Where do you make them / how do you organize them? Now I have one folder with over 60 classes and it becomes cluttered. Rate the offers!

+3
source share
2 answers

Domain objects must live in a separate domain model library. Everything that supports the domain model in a neutral way (for example, no references to ASP.NET MVC, WCF, WPF, etc.) Belongs to the domain model.

The classes that translate between the domain model and the specific interface infrastructure (ASP.NET MVC in your case) belong to this particular project (your ASP.NET MVC project).

You may have your cartographers, etc. in a separate Mappers folder, but personally, I find it much more valuable to structure the code by function instead of infrastructure.

+5
source

<CompanyName>.<ProjectName>.Core , , . , DTO, DAO, , , .

<CompanyName>.<DotNetLibraryNamespace> , ​​ . , <CompanyName>.Text. .net, , .net, .

+1

Source: https://habr.com/ru/post/1715399/


All Articles