我是DDD 领域驱动开发实施的新手。我从网上查看了一些项目源代码,他们使用 DDD 模式实现了这些源代码。在项目结构中,我发现了DTO以及Commands。我需要了解这两者之间有什么区别?这不是代码重复吗?
下面是项目中存在的两个 DTO 和 Command 示例类。
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 …Run Code Online (Sandbox Code Playgroud)