Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion _docs/language-reference/aggregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions _docs/language-reference/bounded-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,32 @@ 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:

| | _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/).
Expand All @@ -179,5 +205,7 @@ 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.
* 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/).
4 changes: 4 additions & 0 deletions _docs/language-reference/language-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)