Let's say I have two bounded contexts, the Shipping Context and the Billing Context. Each of these contexts need to know about the customer.
At a data level, the customer is represented by a CustomerTbl
table in a database. This table consists of all the necessary columns that describe the customer.
Columns in CustomerTbl
(simplified):
Name
PhysicalAddress
PaymentMethod
The Shipping Context is concerned with Name
and PhysicalAddress
while the Billing Context is concerned with Name
and PaymentMethod
.
In the Shipping Context I have modeled the aggregate Recipient
:
Recipient
now has properties/value objects forName
andPhysicalAddress
In the Billing Context I have modeled the aggregate Payer
:
Payer
has properties/value objects forName
andPaymentMethod
Both Recipient
and Payer
aggregates are completely separated by the context boundary. They also have their own repositories.
Questions:
Is it acceptable to have multiple aggregates (provided that they are in separate bounded contexts) using the same "database table"?
Customer data would likely be needed in many more bounded contexts. Would this not mean many aggregate, repository and factory implementations for each bounded context? There will be a degree of redundancy in code. Does this not effect maintainability?
Is it acceptable to have shared properties across aggregates? An example would be the customer
Name
property. This would also mean redundant validation code?