Which layer should be used for conversion to DTO from Domain Object

I think there is no “better way” for converting your domain objects to your DTO objects, it’s a matter of taste. In my projects I convert the domain objects to the DTO in the service layer as part of my “business logic”. So you reduce the accessability of your domain objects only to your service layer. Furthermore I want to reduce the “logic” inside my controllers as they are part of the application layer.

PS: If you are looking for several ways to convert your domain objects to your DTOs have look at one of my latest Stackoverflow questions (How to properly convert domain entities to DTOs while considering scalability & testability)

Leave a Comment