Best Practices For Mapping DTO to Domain Object?

前端 未结 11 1327
执念已碎
执念已碎 2020-11-28 19:43

I\'ve seen a lot of questions related to mapping DTOs to Domain Objects, but I didn\'t feel they answered my question. I\'ve used many methods before and have my own opinio

11条回答
  •  执念已碎
    2020-11-28 20:22

    How do you see to implement a constructor inside the DTO class that takes as a parameter a domain object?

    Say... Something like this

    class DTO {
    
         // attributes 
    
         public DTO (DomainObject domainObject) {
              this.prop = domainObject.getProp();
         }
    
         // methods
    }
    

提交回复
热议问题