jeudi 16 juin 2016

Should DTOs use inheritance or composition

In SOA if a few DTO classes have some fields that are repeated across. Is it better to use Composition or Inheritance so there is not repetition OR just use one DTO class that encapsulates all fields.As my DTO classes grow I see lot of repetitive field names and Sonar report is crying fowl. What is the best approach(or an alternative).

e.g.

public class DocDto{
private Long id;
private String name;
private String docType
}

public class DocReviewDto{
private Long id;
private String name;
private String status;
private String comment;
}

Aucun commentaire:

Enregistrer un commentaire