-1

What is the difference between a Response Object and DTO in software architecture? Say I want to get a list of Products in a catalog.

If ProductDTO is this, how is a Product Response class different? Is a Product Response typically just a wrapper on DTO with datetime, error log, or guid, or what is the prime difference? Would like to hear architectural difference between the two.

public class ProductDto
{
    public int ProductId { get; set;},
    public string ProductName { get; set;},
    public string ProductDescription { get; set;},
    public float SalesAmount { get; set;}
}

Resources below do not have specific answer to question,

https://stackoverflow.com/questions/44349199/reusing-dto-for-various-request-response-types-vs-explicitness-of-what-is-requir

Data Objects for each layer(DTO vs Entity vs Response objects)

Note: Question is rejected on Stackoverflow (its more architectural question), so posting here.

0

2 Answers 2

2

The DTO is just data related to the object, in this case a product.

A response could contain more information other than the just the productDTO. The response could be an aggregate of multiple DTOs. It also could contain META information like an ID or other type of information. Maybe it will return a success/fail code or other business information

<Response>
 <OtherData/>
 <ProductDto/>
</Response>

It's really just a wrapper for the productDTO. The response could just contain the product as well and no other information.

3
  • The response could be an aggregate of multiple DTOs. It also could contain META information like an ID or other type of information. Maybe it will return a success/fail code or other business information.
    – Jon Raynor
    Sep 23, 2019 at 17:43
  • accepted answer and gave points, feel free to thumbs up question also Sep 23, 2019 at 18:54
  • also, apparently question was not removed on stackoverflow, you are welcome to answer, here, and I can send points, thanks or find a way to merge questions, stackoverflow.com/questions/58057598/… Sep 23, 2019 at 18:55
0

Generally, we use DTO for the purpose of user interaction with the database. While we use a response object as a response of the API.

HttpResponse is a response code for API which is used for database operation while DTOs are used as a view model in the application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.