Wednesday, December 25, 2013

Good Transfer Object Hierarhy

One approach worked well for me. Allow me to show by example.
class UserTO {
 private Long id;
 ...

 public Long getId() {
  return id;
 }

 public void setId(Long id) {
  this.id = id;
 }
 ...
}

class UserHistoryTO {
 private Long id;
 ...

 public Long getId() {
  return id;
 }

 public void setId(Long id) {
  this.id = id;
 }
 ...
}

class UserDetailsTO extends UserTO {
 private List<UserHistoryTO> userHistory;
 ...

 public List<UserHistoryTO> getUserHistory() {
  return userHistory;
 }

 public void setUserHistory(List<UserHistoryTO> userHistory) {
  this.userHistory = userHistory;
 }
 ...
}
Do you see the point? Ok, whatever.

No comments:

Post a Comment