Defining request and response models
In the previous section, our use cases worked directly with primitive types and dictionaries. While this approach can work for simple cases, as our application grows, we need more structured ways to handle data crossing our architectural boundaries. Request and response models serve this purpose, providing specialized DTOs that handle data transformation between the outer layers and our application core. Building on the information hiding principles we introduced earlier, these models extend this concept to architectural boundaries, specifically protecting our domain logic from external format details while shielding external interfaces from domain implementation specifics. This reciprocal boundary protection is particularly important as different interfaces evolve at different rates.
Request models
Request models capture and validate incoming data before it reaches our Application layer’s use cases. They provide a clear structure...