hi,all
context:
I have a project about Product Management System. The operator can add new product with it .
question:
As a product , some info (property) is optional and some is mandatory. How to design command object for product creation, if contain the optional info ?
In my opinion, the create command should only contain mandatory info ,and the optional info can be updated after creation.
any suggestion?
sample code (may be):
class CreateProductCommand
{
private String name; //mandatory
private String catId; //mandatory
public CreateProductCommand(String name,String catId)
{
this.catId=catId;
}
some get method...
}
class Product
{
private String uuid; //mandatory
private String name; //mandatory
private String catId; //mandatory
private String description; //optional
public Product(String uuid,String name,String catId)
{
apply(new ProductCreatedEvent(...));
}
}