Problem Statement
When should you introduce a Data Transfer Object (DTO) instead of exposing domain entities directly?
Explanation
DTOs shape data for the outside world without leaking internal fields or invariants. This lets you version your API safely and keep domain rules inside entities.
They also reduce over-fetching and stabilize clients when your domain evolves internally.
Code Solution
SolutionRead Only
class OrderDTO{ id:string; total:number; items:ItemDTO[] }
class Order{ id:Id; money:Money; lines:OrderLine[] }Practice Sets
This question appears in the following practice sets:
