Skip to content

Add owner to BoundedContext (#161) - #386

Open
stefan-ka wants to merge 4 commits into
feature/375-base-packagefrom
feature/161-bounded-context-owner
Open

stefan-ka wants to merge 4 commits into
feature/375-base-packagefrom
feature/161-bounded-context-owner

Conversation

@stefan-ka

@stefan-ka stefan-ka commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Part of #161 (the issue stays open for the follow-up questions listed below).

Stacked on #385; the base branch is feature/375-base-package, so the diff only shows this feature.

Changes

  • Grammar: new optional owner attribute on BoundedContext (reference to a Bounded Context, = optional), like the existing owner on Aggregates:
    BoundedContext TicketSales implements FareSales {
      owner = FareProductTeam
    }
    
    BoundedContext FareProductTeam realizes TicketSales {
      type = TEAM
    }
    
  • Validator: the owner must be a Bounded Context of type TEAM (same message as for Aggregate owners).
  • Formatter: owner starts on a new line.

Owner vs. realizes

Team realizes BC says which teams work on a context (many-to-many); owner names the one team that is accountable for it, declared on the context itself. The owner is meant to be one of the realizing teams. Two new warnings keep both consistent:

  • The owner of a context does not realize it, but other teams do.
  • The owner of an Aggregate neither owns nor realizes the Aggregate's context.

Both only apply if the context has an owner or realizing teams, so existing models get no new warnings.

Split Bounded Context by Owners

If the context has an owner:

  • Aggregates without an own owner belong to the context's owner.
  • The owner's Aggregates stay in the original context. Before, the group that stayed depended on HashMap order.
  • The new contexts get the team of their Aggregates as owner.

Contexts without an owner are split exactly as before.

Generators

  • PlantUML component diagram: Owner: <team> in the note of the component (the note is now also printed when there is no domain vision statement).
  • MDSL: // Owner: <team> on the API provider and client.
  • Freemarker sample templates (samples/freemarker/markdown-templates/bounded-contexts): owner in the simple and the detailed Bounded Context list. Custom templates can use ${bc.owner.name}.

Not included

owner was already a keyword (Aggregates), so no highlighting change in the VS Code extension is needed.

Docs: ContextMapper/contextmapper.github.io#107

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.41176% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.7%. Comparing base (bb9e147) to head (d42e166).

Files with missing lines Patch % Lines
...tmapper/dsl/validation/TeamSemanticsValidator.java 84.3% 2 Missing and 3 partials ⚠️
...er/dsl/refactoring/SplitBoundedContextByOwner.java 83.3% 0 Missing and 2 partials ⚠️
...ator/plantuml/PlantUMLComponentDiagramCreator.java 93.3% 0 Missing and 1 partial ⚠️
...oring/SplitBoundedContextByAggregateAttribute.java 93.3% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##             feature/375-base-package    #386     +/-   ##
============================================================
- Coverage                        91.8%   91.7%   -0.1%     
- Complexity                       2237    2280     +43     
============================================================
  Files                             211     211             
  Lines                            5961    6027     +66     
  Branches                          811     828     +17     
============================================================
+ Hits                             5474    5532     +58     
- Misses                            232     234      +2     
- Partials                          255     261      +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan-ka
stefan-ka force-pushed the feature/375-base-package branch from 0389a6f to c1b9e4f Compare October 20, 2026 21:55
@stefan-ka
stefan-ka force-pushed the feature/161-bounded-context-owner branch from 628a2fe to 4b1752c Compare October 20, 2026 21:55
@stefan-ka
stefan-ka marked this pull request as ready for review November 19, 2026 16:08
A Bounded Context can name the team that owns it:

  owner = FareProductTeam

As for Aggregates, the owner must be a Bounded Context of type TEAM.
@stefan-ka
stefan-ka force-pushed the feature/375-base-package branch from c1b9e4f to bb9e147 Compare November 19, 2026 16:33
@stefan-ka
stefan-ka force-pushed the feature/161-bounded-context-owner branch from 4b1752c to 4fd9ca5 Compare November 19, 2026 16:33
…161)

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 context has an owner or
realizing teams.
If the context has an owner, Aggregates without an own owner belong to it,
the owner's Aggregates stay in the original context, and the new contexts
are owned by the team of their Aggregates. Contexts without an owner are
split as before.
- PlantUML component diagram: owner in the note of the component
- MDSL: owner comment on API providers and clients
- Freemarker sample templates: owner in the Bounded Context lists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant