1

I have asked a similar question before, but I still struggle to 'get' this.

I have a bounded context that is UserManagement which contains all the details about User, UserId etc. This is separated as a context as it is useable in two separate applications.

I have another bounded context that stores all the reusable code, as my Core. In the core, there is a Shareable concept (an interface and trait in PHP) but this makes use of the UserId from my other bounded context.

As the core is the lowest part of my domain, surely I should not be referencing objects in a layer above it? Should Shareable use a more generic Identifier concept over a concrete UserId?

This question also confuses me with general use of Id objects across different bounded contexts; should I reference UserId in other contexts, or create an implementation of UserId in each one?

2

You MAY have different objects for each bounded context, however it's not necessary. If a user is present in both bounded context A and B and is essentially the same thing it would be actually unwise not to reuse the existing entities you have at hand.

Splitting your application into multiple bounded contexts happens when your application and domain is so large a single context can no longer hold the entire information well together, when multiple domain experts express maybe similar concepts using different ideas. That's the point where you want to make the context difference apparent. But still, if you have a let's say support context where you take care of users in your system and you have another application context where the users actually live the users should in both cases be the same, to show that you are in fact working with the same data.

In your case it's perfectly valid to reuse the UserId value object.

  • Thanks. After reading your answer, I think I may have applied Bounded Contexts where they might not be needed. Although User might still be relevant, all the other parts might not and I may squish them together. – designermonkey Jul 6 '17 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.