N
N
nikitosis2019-05-26 08:21:51
Java
nikitosis, 2019-05-26 08:21:51

What is the correct way to use dto in this situation?

In general, I want to make an API for my mobile application.
Let's say I have Product(id,name,categories(list),picture,description,ect)
And in some situation I just need to display a list of Product in the application.
As I understand it, you can use some DTO for this: ProductListItem(name,picture) and pass it.
Then I need to show more detailed information about the product, then I need to use another DTO ProductInfo(name,picture,description) and pass it.
1. Is this a good way to work with DTOs?
2. In this situation, for almost every user action, I need to send a request to the server to get a specific DTO. How can the effectiveness of this approach be improved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat Khayrutdinov, 2019-05-27
@distrik

The approach is quite good. It is good because your colleague does not have to guess in what situation which fields to fill in. But everything is good in moderation. If you have a lot of such cases, then it may be too expensive to describe each individual ATT, and besides, a colleague will get confused in their huge number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question