I've the following project structure (simplified):
- domain
- dto
- view
In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req, *res classes to pass the data via HTTP. So there are 3 classes (in model, dto and view) to express the same thing.
The problem is that I had a SalesEntry and PurchaseEntry in the model. Both classes where exactly the same so I had two entities but only one EntryDto along with EntryReq and EntryRes. All good. Now, it turned out that I need to add some fields but, to PurchaseEntry only. So I added some abstraction and doubled the classes in every layer. This was a big cost. Where did I go wrong and how should it be done correctly?
In languages other than java I'd probably pass some maps here and there, but in java in particular I need to have a concrete class in every layer. How to simplify it?
dtoobjects to return the model data. But I don't want usedtoto transport data via HTTP layer. That's the question, what am I doing wrong? ;)