有限的上下文实现和设计 [英] Bounded context implementation and design

本文介绍了有限的上下文实现和设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有两个有界上下文,即 Shipping Context Billing Context .这些上下文中的每一个都需要了解客户.

Let's say I have two bounded contexts, the Shipping Context and the Billing Context. Each of these contexts need to know about the customer.

在数据级别,客户由数据库中的CustomerTbl表表示.该表包含描述客户的所有必要列.

At a data level, the customer is represented by a CustomerTbl table in a database. This table consists of all the necessary columns that describe the customer.

CustomerTbl中的列(简体):

  • Name
  • PhysicalAddress
  • PaymentMethod
  • Name
  • PhysicalAddress
  • PaymentMethod

运输上下文NamePhysicalAddress有关,而计费上下文NamePaymentMethod有关.

The Shipping Context is concerned with Name and PhysicalAddress while the Billing Context is concerned with Name and PaymentMethod.

运输环境中,我对聚合Recipient进行了建模:

In the Shipping Context I have modeled the aggregate Recipient:

  • Recipient现在具有NamePhysicalAddress
  • 的属性/值对象
  • Recipient now has properties/value objects for Name and PhysicalAddress

结算上下文中,我对聚合Payer进行了建模:

In the Billing Context I have modeled the aggregate Payer:

  • Payer具有用于NamePaymentMethod
  • 的属性/值对象
  • Payer has properties/value objects for Name and PaymentMethod

RecipientPayer聚合均被上下文边界完全分隔.他们也有自己的存储库.

Both Recipient and Payer aggregates are completely separated by the context boundary. They also have their own repositories.

  1. 使用同一数据库表"具有多个聚合(假设它们在单独的有界上下文中)是否可以接受?

  1. Is it acceptable to have multiple aggregates (provided that they are in separate bounded contexts) using the same "database table"?

在更多有限的上下文中可能需要客户数据.这是否意味着每个有限的上下文都有许多聚合,存储库和工厂实现?代码中会有一定程度的冗余.这不会影响可维护性吗?

Customer data would likely be needed in many more bounded contexts. Would this not mean many aggregate, repository and factory implementations for each bounded context? There will be a degree of redundancy in code. Does this not effect maintainability?

跨聚合具有共享属性是否可以接受?例如,客户Name属性.这还意味着冗余验证代码吗?

Is it acceptable to have shared properties across aggregates? An example would be the customer Name property. This would also mean redundant validation code?

推荐答案

Q& A

1)使用同一数据库表"具有多个聚合(假设它们在单独的有界上下文中)是否可以接受?

1) Is it acceptable to have multiple aggregates (provided that they are in separate bounded contexts) using the same "database table"?

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆