Where put a common value object between two bounded contexts?

Viewed 1623

i'm trying to apply the domain driven design in a little project i want to separate the authentication of rest of the users logic, i'm using a value object for the id (userID) in the beginning i have the userID in the same level(package) of the users but I realize when i separate bounded context for authentication and user, they share a common value object for the userID, so my question is where supose that i have to put the common or share value objects? is correct if i created a packages called commons?

3 Answers

First of all, I personally see this as an context mapping question at code level, where you are effectively looking to have a shared kernel between multiple bounded contexts.

This depends on the business really. You typically need to consider the following questions:

  • How do different teams responsible for each bounded context collaborate with each other? If it's 1 team maintaining all the related bounded contexts, it might be OK, but it's multiple teams have different objectives, it leads to the next point.
  • How do you plan to maintain this shared kernel over time? In general, this shared kernel will need to change to adapt to business changes.

For more detailed arguments, there are plenty of resources out there about context mapping, such as Vaughn Vernon's book "Implementing Domain Driven Design".

Related