mercredi 26 février 2020

Should two java domain classes be joined into one if almost all fields are the same?

I have two reports that I am creating. I first map the data from a db query to a domain object. There are about 55 fields in one and 51 fields in the other report.

However 49 of the fields from the first report with 55 fields are also in the second report with 51 fields.

Would it be better to have them as separate classes and more decoupled or combine them into one generic "report" class/object?

I don't think creating a parent class with the common fields and have 2 classes extend from them is the best approach since it's a domain object so only getters and setters and then the subclass would have like only 2 fields, seems a bit much.

Would joining these two classes be considered a DTO? Is a DTO only when you create another object from the domain object that fits your presentation layer requirements i.e has only the required data.

Aucun commentaire:

Enregistrer un commentaire