Hi
I am struggling a bit with the design of my command (and events).
What are best practices or recommended patterns for designing commands?
Assume there is an aggregate Operator that handles a commend to add a postal address:
Option 1: POJO-style command:
@Value
@Builder
class AddPostalAddressCommand {
@TargetAggregateIdentifier
OperatorId operatorId;
String street;
String streetNumber;
String postalCode;
String city;
String country;
}
Option 2: Use value objects from the model also in the commands (and events):
@Value
@Builder
class AddPostalAddressCommand {
@TargetAggregateIdentifier
OperatorId operatorId;
PostalAddress postalAddress; // value object from my model
}
The value object approach feels more DDD-like, but on the other hand side this leads to value objects “leaking” out of my model. I’ll end up with a lot of value objects in my API (commands+events).
Any suggestions/opinions on this?
Thanks
Klaus