From 6e929cf18498f390dda5214a0ba87777ee79d997 Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Mon, 19 Oct 2026 22:50:34 +0200 Subject: [PATCH 1/2] Document owner attribute on Bounded Contexts Documentation for ContextMapper/context-mapper-dsl#161. --- _docs/language-reference/aggregate.md | 2 +- _docs/language-reference/bounded-context.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/_docs/language-reference/aggregate.md b/_docs/language-reference/aggregate.md index 64b6eaf..8640dd3 100644 --- a/_docs/language-reference/aggregate.md +++ b/_docs/language-reference/aggregate.md @@ -151,7 +151,7 @@ CREATED, CHECK_REQUESTED -> ACCEPTED X REJECTED _Hint:_ You can also model the state transition inside your [event flows in the application layer](/docs/application-and-process-layer/#processes-and-eventcommand-flows). ## Aggregate Owner -CML allows specifying an owner on the aggregate level. If aggregates are maintained by different teams, you can specify this as in the +CML allows specifying an owner on the aggregate level (and on the [bounded context](/docs/bounded-context/#bounded-context-owner) level). If aggregates are maintained by different teams, you can specify this as in the following example: ```cml diff --git a/_docs/language-reference/bounded-context.md b/_docs/language-reference/bounded-context.md index f813296..d142eeb 100644 --- a/_docs/language-reference/bounded-context.md +++ b/_docs/language-reference/bounded-context.md @@ -166,6 +166,20 @@ BoundedContext CustomersBackofficeTeam implements CustomerManagementDomain reali } ``` +### Bounded Context Owner +With the _owner_ attribute you can name the team that owns a bounded context. The owner must be a bounded context of the type TEAM: + +```cml +BoundedContext TicketSales implements FareSales { + owner = FareProductTeam +} + +BoundedContext FareProductTeam realizes TicketSales { + type = TEAM +} +``` + +While _realizes_ (on the team) states which bounded contexts a team implements, _owner_ (on the bounded context) states who is accountable for it, for example who has to approve changes to its model and code. If different teams maintain different parts of a bounded context, you can additionally specify an owner per [Aggregate](/docs/aggregate/#aggregate-owner). ## The Bounded Context Building Blocks Within a bounded context, you can create _Modules_ and _Aggregates_ as illustrated in the example at the beginning of this page. On this tactical DDD level we integrated the [Sculptor DSL](https://sculptor.github.io/). @@ -179,5 +193,6 @@ Note that semantic rules (validators) exist for bounded contexts within CML. Thi The following rules apply to a bounded context: * The _realizes_ keyword of the bounded context rule can only be used if the type of the bounded context is TEAM. +* The _owner_ attribute must refer to a bounded context of the type TEAM. For a summary of all semantic rules and justifications, please consult [Language Semantics](/docs/language-model/). From e7d6fdaf7bfb25f0475f8e3e20a0054760da7a3e Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Thu, 19 Nov 2026 17:42:56 +0100 Subject: [PATCH 2/2] Document owner vs. realizes, the owner warnings and owners in generated artifacts --- .../ar-split-bounded-context-by-owners.md | 5 +++++ _docs/language-reference/aggregate.md | 3 +++ _docs/language-reference/bounded-context.md | 15 ++++++++++++++- _docs/language-reference/language-model.md | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/_docs/architectural-refactorings/ar-split-bounded-context-by-owners.md b/_docs/architectural-refactorings/ar-split-bounded-context-by-owners.md index 078bc46..2f27e5a 100644 --- a/_docs/architectural-refactorings/ar-split-bounded-context-by-owners.md +++ b/_docs/architectural-refactorings/ar-split-bounded-context-by-owners.md @@ -39,6 +39,11 @@ aggregates which are owned by different teams. ## Output * The AR creates multiple bounded contexts. Each bounded context contains one or more aggregates which are owned by the same team. + +If the bounded context has an [owner](/docs/bounded-context/#bounded-context-owner): + * Aggregates without an owner belong to the owner of the bounded context. + * The aggregates of the bounded context's owner stay in the original bounded context. + * The new bounded contexts are owned by the team of their aggregates. ## Example The following example illustrates how this AR can be applied. The corresponding sources can be found in our diff --git a/_docs/language-reference/aggregate.md b/_docs/language-reference/aggregate.md index 8640dd3..aab0a57 100644 --- a/_docs/language-reference/aggregate.md +++ b/_docs/language-reference/aggregate.md @@ -187,6 +187,9 @@ BoundedContext CustomerSelfServiceContext implements CustomerManagementDomain { The _owner_ attribute may be used for service decomposition by using the [Split Bounded Context by Owners](/docs/ar-split-bounded-context-by-owners) architectural refactoring. +If the bounded context has an [owner](/docs/bounded-context/#bounded-context-owner) or teams realizing it, the owner of an aggregate should be one of these teams. +Otherwise, Context Mapper shows a warning. Aggregates without an owner belong to the owner of their bounded context. + Note that the _owner_ attribute refers to a team, which must be a bounded context of the type _TEAM_: (see [Bounded Context](/docs/bounded-context) for more details): ```cml diff --git a/_docs/language-reference/bounded-context.md b/_docs/language-reference/bounded-context.md index d142eeb..eda6f55 100644 --- a/_docs/language-reference/bounded-context.md +++ b/_docs/language-reference/bounded-context.md @@ -179,7 +179,19 @@ BoundedContext FareProductTeam realizes TicketSales { } ``` -While _realizes_ (on the team) states which bounded contexts a team implements, _owner_ (on the bounded context) states who is accountable for it, for example who has to approve changes to its model and code. If different teams maintain different parts of a bounded context, you can additionally specify an owner per [Aggregate](/docs/aggregate/#aggregate-owner). +While _realizes_ (on the team) states which bounded contexts a team implements, _owner_ (on the bounded context) states who is accountable for it, for example who has to approve changes to its model and code: + +| | _realizes_ | _owner_ | +|---|---|---| +| Question | Which teams work on the bounded context? | Which team is accountable for it? | +| Cardinality | A bounded context can be realized by several teams, and a team can realize several bounded contexts. | A bounded context has one owner. | +| Declared on | The team | The bounded context | + +The owner is meant to be one of the teams realizing the bounded context. If you model both, Context Mapper shows a warning if the owner does not realize the bounded context while other teams do. If you don't model which teams realize a bounded context, the _owner_ alone is fine. + +If different teams maintain different parts of a bounded context, you can additionally specify an owner per [Aggregate](/docs/aggregate/#aggregate-owner). Aggregates without an owner belong to the owner of their bounded context, for example when you [split a bounded context by owners](/docs/ar-split-bounded-context-by-owners/). + +The owner is shown in the [PlantUML component diagram](/docs/plant-uml/) (in the note of the bounded context) and in the generated [MDSL contracts](/docs/mdsl/) (as a comment on the API provider and client). In [Freemarker templates](/docs/generic-freemarker-generator/), you can access it with `${bc.owner.name}`. ## The Bounded Context Building Blocks Within a bounded context, you can create _Modules_ and _Aggregates_ as illustrated in the example at the beginning of this page. On this tactical DDD level we integrated the [Sculptor DSL](https://sculptor.github.io/). @@ -194,5 +206,6 @@ The following rules apply to a bounded context: * The _realizes_ keyword of the bounded context rule can only be used if the type of the bounded context is TEAM. * The _owner_ attribute must refer to a bounded context of the type TEAM. +* The _owner_ should be one of the teams realizing the bounded context, if teams realizing it are modeled (warning). For a summary of all semantic rules and justifications, please consult [Language Semantics](/docs/language-model/). diff --git a/_docs/language-reference/language-model.md b/_docs/language-reference/language-model.md index 76a86ac..8289138 100644 --- a/_docs/language-reference/language-model.md +++ b/_docs/language-reference/language-model.md @@ -70,6 +70,10 @@ Only teams can realize bounded contexts. This checker ensures that the *realize* The keyword is added to the language definition in order to reference the bounded contexts a team is realizing. It would not make sense for a classical bounded context (system, feature or application). +**\#11: Owners and realizing teams:** +The owner of a bounded context should be one of the teams realizing it, and the owner of an aggregate should own or realize the aggregate's bounded context. +Both checks only apply if the bounded context has an owner or teams realizing it, and they produce warnings, not errors. + ## Links * We presented the CML meta-model and the rules above in the following conference paper: [Domain-specific Language and Tools for Strategic Domain-driven Design, Context Mapping and Bounded Context Modeling](https://doi.org/10.5220/0008910502990306)