In a demo project I am setting up as a proof of concept I am finding myself with a lot of duplicated DTOs and fields. For instance considering 1 root object representing an item or inventory, I would have the following classes and properties
- CreateItem [ Code, Description, Weight ]
- Entity on aggregate root [ Code, Description, Weight ]
- ItemCreated event [ Code, Description, Weight ]
- Item read model [ Code, Description, Weight ]
- Query request object [ Code, Description, Weight, Page, PageSize ]
- Response DTO [ Code, Description, Weight ]
- and so on
All these objects are a result of separating my app into the traditional Domain, Application, Presentation layers.
How are you managing all this duplication? Tools like AutoMapper and such help to convert between them, but if I wanted to add a new property to Item that would be used everywhere I would have to update all these models.
Because the domain model may not be exactly the same as the application read model, I understand the need for separate definitions, however this can very quickly become a maintenance nightmare.