Loading lesson…
Level 1 · Apprentice0 XP
Keep database rows, API payloads and domain objects separate, and map between them.
Step 1 / 5
ProblemThe same User class is the table row, the JSON in the API and the object used by the rules. Adding a column leaks into the public API. Renaming a JSON field breaks the database mapping.
← → step
Before this: Ports and adapters in depth
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Create three shapes for a product: ProductRow (id, name, price_cents, internal_cost_cents), Product (domain) and ProductDto for the API. Write the mappers and make sure internal_cost_cents can never reach the DTO.