Bounded Contexts in DDD with CQRS. Sharing Aggregates/Entities. Possible?

孤街醉人 提交于 2019-12-01 07:32:56

A shared kernel introduces very tight coupling between the CRM and Sales BC.

Here is an alternative..

The CRM BC owns customers. You don't necesarrily have to duplicate the complete customer AR in the Sales BC. This avoids having to deal with two-way synchronization. You could make the Client AR in the Sales BC reference the Customer AR in the CRM BC by its identifier, and then keep the specific Client properties encapsulated in the Sales BC. This creates a conformist or customer-supplier relation between the Sales and CRM BC, where the Sales BC is downstream and the CRM BC upstream. The CRM context will probably use an open-host service to make the Customer AR available to the Sales BC.

Generally reuse across contexts isn't encouraged. There may be rare cases where a shared kernel could help, but usually domain objects (and aggregates thereof) should be kept local to their respective context. Otherwise you'd introduce tight coupling and lose one of the main advantages of bounded contexts. They won't be able to change and evolve independently of eachother.

Bounded contexts will often be implemented by different teams and for different customers (in the example the Sales department and Customer relations department). They will both have their own view on a customer and I think the project is trying to exaggerate that point by naming them differently.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!