Views: 16.1K
Replies: 3
Archived
|
Data Transfer Objects and Service LayerQuestion 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: return _categoryDao.GetCategories(); Thanks Dennis Dennis Tucker, Jun 11, 2012
|
|
Reply 1Hi, Dennis.
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. Mike Michael Lopez, Aug 04, 2012
|
|
Reply 2The 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
|
|
Reply 3Hi,
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
|