I'm trying to figure out how i approach DDD and the use of Bounded Contexts.
I've tried to come up with an example, to illustrate my question. (I'm using anemic classes for quickness).
I am trying to map out how I would go about separating domain objects within different bounded contexts.
I thought about the domain object that could be an Employee.
Let's say that I have two bounded contexts, the HR Department and the Finance Department.
Generally, the Finance department would require more information about the Employee than the HR Department. The HR Department wouldn't need any information relating to the Employee Bank Details, National Insurance Number or contracted hours. (Maybe in some businesses this isn't quite true, but lets just assume this in the example).
So in two separate contexts, the behavior/interaction required with an Employee is different.
HR Department.
public class Employee
{
public int Id { get; set; }
public Title Title { get; set; }
public string Forename { get; set; }
public string Surname { get; set; }
public Address Address { get; set; }
public DateTime DateOfBrith { get; set; }
public DateTime EmploymentStartDate { get; set; }
}
Finance Department.
public class Employee
{
public int Id { get; set; }
public Title Title { get; set; }
public string Forename { get; set; }
public string Surname { get; set; }
public Address Address { get; set; }
public DateTime DateOfBrith { get; set; }
public string NationalInsuranceNumber { get; set; }
public BankAccount BankAccountDetails { get; set; }
public double ContractedHours { get; set; }
}
Given this example, how do i limit the Employee object in the HR Context, to only have the behavior it requires, and that the Finance Context has the Extended behavior.
If an application was broken up into multiple contexts, all with custom behavior associated to an Employee, how would I model the Employee object.
I have looked at different ways to build your Context map, and a shared Kernel seems promising, but it would mean that all contexts would then share all of the behavior associated to the Employee Domain object.
I would expect that each context would be limited.
Help!