In my current Monolithic application using EventSourcing and CQRS with Java, we have a seperate write and read models.
package com.command;
class Address{ //class created in Command Write model
String address;
}
package com.command;
import com.command.Address;
class CreateEmployeeCommand { //Command class belongs to Write Model
Address address; //this is correct
}
package com.events;
import com.command.Address;
class EmployeeCreatedEvent { //Event class belongs to Read Model
Address address; //this should not be correct IMO, instead seperate Address class should be created in event package.
}
In above Command and Event classes, command model class "Address" has been shared between them. I am thinking above is not correct, instead seperate Address classes should be created for each Read and Write model. By using above approach, are we violating like seperation of concerns principle? and what other real issues do we really face if we share same Command models between Command and Event classes. Please let me know whether I am thinking correct or wrong..