Issue
That's a silly question but I had this question during the interview of a some company. I had a stateless backend using Java Spring and expected the full DTO from the request as a @RequestBody but they asked me what are the drawbacks of expecting a full DTO as @RequestBody and I couldn't answer it.
If my application is stateless, how should I expect the model from the controller? Or is stateless backend not a good idea if you expect the whole model to use it in the service-side?
Solution
- With DTO you usually send more data that is actually needed by remote server (although one of the main point of DTO is to reduce the number of remote calls by sending more data)
- It maybe not straightforward to transfer DTOs to domain objects, if DTOs were complex
- Serialization/de-serialization also could be a burden[for example binary or text]. but if you control both client and server it is not a big deal.
- With big DTOs it become harder to keep clients and servers synchronized of changes
Answered By - hatef alipoor
Answer Checked By - David Marino (JavaFixing Volunteer)