I am new to DDD-Domain Driven Development implementation. I have checked out a few projects source code from online which they have implemented using the DDD pattern. In the project structure, I found DTO as well as Commands. I need to understand what is difference between these two? and is it not code duplication?
Below are two example classes of DTO and Command that exist in the project.
public class BookCargoCommand {
private String bookingId;
private int bookingAmount;
private String originLocation;
private String destLocation;
private Date destArrivalDeadline;
public BookCargoCommand(){}
public BookCargoCommand(int bookingAmount,
String originLocation, String destLocation, Date destArrivalDeadline){
this.bookingAmount = bookingAmount;
this.originLocation = originLocation;
this.destLocation = destLocation;
this.destArrivalDeadline = destArrivalDeadline;
}
public void setBookingId(String bookingId){ this.bookingId = bookingId; }
public String getBookingId(){return this.bookingId;}
public void setBookingAmount(int bookingAmount){
this.bookingAmount = bookingAmount;
}
public int getBookingAmount(){
return this.bookingAmount;
}
public String getOriginLocation() {return originLocation; }
public void setOriginLocation(String originLocation) {this.originLocation = originLocation; }
public String getDestLocation() { return destLocation; }
public void setDestLocation(String destLocation) { this.destLocation = destLocation; }
public Date getDestArrivalDeadline() { return destArrivalDeadline; }
public void setDestArrivalDeadline(Date destArrivalDeadline) { this.destArrivalDeadline = destArrivalDeadline; }
}
and
public class BookCargoResource {
private int bookingAmount;
private String originLocation;
private String destLocation;
private LocalDate destArrivalDeadline;
public BookCargoResource(){}
public BookCargoResource(int bookingAmount,
String originLocation, String destLocation, LocalDate destArrivalDeadline){
this.bookingAmount = bookingAmount;
this.originLocation = originLocation;
this.destLocation = destLocation;
this.destArrivalDeadline = destArrivalDeadline;
}
public void setBookingAmount(int bookingAmount){
this.bookingAmount = bookingAmount;
}
public int getBookingAmount(){
return this.bookingAmount;
}
public String getOriginLocation() {return originLocation; }
public void setOriginLocation(String originLocation) {this.originLocation = originLocation; }
public String getDestLocation() { return destLocation; }
public void setDestLocation(String destLocation) { this.destLocation = destLocation; }
public LocalDate getDestArrivalDeadline() { return destArrivalDeadline; }
public void setDestArrivalDeadline(LocalDate destArrivalDeadline) { this.destArrivalDeadline = destArrivalDeadline; }
}
Note: Since I could not find the exact question, I placed it. Kindly someone let me know if a similar question exists in StackOverflow.
command/event
,request/response
, ormodel
. – Sayyid