AR-5: Extract Aggregates by Cohesion

Extracts a set of aggregates which are chosen by certain cohesion criteria and moves them to a separate bounded context.

Context & Rationales

By decomposing a system into multiple bounded contexts we aim for loose coupling between the bounded context and a high cohesion within them. There are many different approaches and different coupling criteria by which the software architect may want to decompose a system into components.

See also:

Goal

This Architectural Refactoring (AR) allows to manually select the aggregates which should be extracted by any coupling criteria or Non-functional Requirements (NFR). The goal of this AR is to isolate a set of aggregates within a new bounded context by an individual criterion.

Inverse AR’s:

Preconditions

  • The selected bounded context must contain at least two aggregates.

Input

  • One bounded context.
  • A selection of aggregates which shall be extracted to a new bounded context.

Output

  • A new bounded context containing the selected aggregates.

Example

The following example illustrates how this AR can be applied. The corresponding sources can be found in our examples repository.

Input

The bounded context in the example contains multiple aggregates. The AR is available on this bounded context:

Extract Aggregates by Cohesion Example Input

Manual Selection Dialog

Once you triggered the refactoring a dialog will pop up, allowing you to choose a name for the new bounded context and the aggregates which should be extracted:

Extract Aggregates by Cohesion Example Dialog

Note that if you select all Aggregates within this dialog you end up with an empty Bounded Context, since everything is moved to a new Bounded Context. From our perspective selecting all Aggregates does therefore not make much sense. You can alternatively simply rename the existing Bounded Context.

Result

The resulting model contains a new bounded context with the selected aggregates:

Extract Aggregates by Cohesion Example Output

Example Sources

  • You can find the CML sources for this AR example here.