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.
In my experience/opinion it is best to issue a single create command containing both mandatory and optional data.
A common use case is user registration. Here, the command to create the user usually contains the user id and user profile. This user profile might be rudimentary with little useful data if the signup process is basic but the advantage is that a subsequent command to edit the user profile also contains a user profile object. This way, both commands share the same language which usually makes life easier.
In general, it should be clear what the intent of a command is. By splitting up your command it is harder for your aggregate to know what’s going when it needs to handle the second command.
if the command contains all datas, handler will use ALL data to create new ENTITY(product,above sample), and entity should have a constructor with ALL parameters.
according to the business, some optional data can be ignored when entity created, so that confuses me.
should I add a constructor of entity class with ALL OPTIONAL parameters?