I am trying to understand how entities operate in multiple bounded contexts.
Given an Employee of a Company. In (for example) the Human Resources context, this person has a name, surname, address, salary reference number, and bank account. But in the Accounting context all that is relevant is the salary reference number and bank account.
Do you have an Employee entity in the HR context and a Value-Type (e.g. SalariedEmployee
) in the Accounting context?
class Employee
{
public BankAccount BankAcountDetails { get; set; }
public string FullName { get; set; }
public Address ResidentialAddress { get; set; }
public string SalaryRef { get; set; }
}
SalariedEmployee
class (??) : Employee's value-type
class SalariedEmployee
{
public SalariedEmployee(string salaryRef, BankAccount bankAcountDetails)
{
...
}
public string SalaryRef { get; }
public BankAccount BankAcountDetails { get; }
}
Does the HRService in the bounded context return this information? Or do you use the Employee class in both contexts?