Data Transfer Objects and Service Layer
Question about the Design Pattern Framework.
What is the purpose of the Data Transfer Objects in the Service Layer?
If I'm not using WCF is it possible to eliminate the DTOs in the Service Layer?
In the code we have:
var categories = _categoryDao.GetCategories();
response.Categories = Mapper.ToDataTransferObjects(categories);
If we did not use WCF we could we simply use:
Dennis Tucker, Jun 11, 2012
DTO's are for sending data across layers and is independent of WCF. They're great in cases where you need to add more data members, as your interface is not broken and, assuming you're employing versioning, can access the new members in your updated methods.
Michael Lopez, Aug 04, 2012
The Dto, for me at least, helps to enforce separation of concerns and in my view are used to
Passing Data between layers using serializable objects - helps with scaling if required later
Stopping business objects being passed from the service layer to the presentation layer
William Jones, Jul 26, 2012
Data Transfer Object or DTO's are mainly used for sending information from one layer to another layer. It doesn't have any relation with WCF services.
Also, I have seen people uses DTO's in two ways:
Both approaches has its pros and cons. It totally depends on your choice what you need.
Vishal Shah, Jun 18, 2012