Demo: separating DTOs from domain models
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
stop serializing domain objects; prepares JNR-013-LAB1.
Draft outline details
Step by step
- Call the endpoint and see the raw
ProductJSON, including internalcostCents. - Create
ProductResponsewith only public fields. - Add a mapper method
toResponse(Product). - Planned mistake: reuse one
ProductDtofor create, update, and response; clients can then send anidor change fields they should not. Fix:CreateProductRequest,UpdateProductRequest,ProductResponse. - Rename a domain field and show the API response does not change.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.