Should DTO be in Service Layer?

Should DTO be in Service Layer?

Not only you could pass DTO objects to Service Layer, but you should pass DTO objects instead of Business Entities to Service Layer. Your service should receive DTOs, map them to business entities and send them to the repository.

What role does the Service Layer play in a domain facade implementation approach?

In the domain facade approach a Service Layer is implemented as a set of thin facades over a Domain Model (116). The thin facades establish a boundary and set of operations through which client layers interact with the application, exhibiting the defining characteristics of Service Layer.

What is meant by service layer?

In intelligent networks (IN) and cellular networks, service layer is a conceptual layer within a network service provider architecture. It aims at providing middleware that serves third-party value-added services and applications at a higher application layer.

Do you return DTOs in the service layer?

IMO the accepted answer promotes something which you should not be doing in the service layer, ie returning your domain objects. Instead, the service layer should encapsulate your domain model and return DTOs via its interface. The mapping should happen inside that layer itself.

Which is an example of a service layer?

According to Martin Fowler: the Service Layer defines the application’s boundery, it encapsulates the domain. In other words it protects the domain. Can you provide an example of this data object? If we should strictly stick to DTOs, should they be defined in service layer? Yes, because the response is part of your service layer.

How are DTOs controlled by the interface layer?

The Interface Layer uses mapping techniques defined within the Interface Layer itself to map from Domain objects to DTOs. Again, this keeps DTOs focused on being adapters that are controlled by the Interface Layer. In my experience you should do what’s practical.

Do you have to implement domain objects in two locations?

Yes, this means that you have to implement your domain objects in two locations; your interface layer and in your BO layer. But that reimplementation, while it may initially seem like extra work, helps enforce the decoupling that will save TONS of work at some point in the future.