AR-4: Extract Aggregates by Volatility
Extracts all aggregates from a bounded context by a given volatility, or likelihood for change (RARELY, NORMAL or OFTEN), and moves them to a separate 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. One approach of decomposing components is to isolate parts which are likely to change.
- Coupling criterion Structural Volatility of ServiceCutter
- On the criteria to be used in decomposing systems into modules by D. L. Parnas
In the Context Mapper DSL you can specify how often an aggregate changes with the likelihoodForChange attribute. See our page aggregate documentation page for more details.
This Architectural Refactoring (AR) extracts all aggregates with a given volatility which is provided as input parameter (RARELY, NORMAL or OFTEN) and moves those aggregates into a new bounded context. Thereby you are able to isolate aggregates with a certain likelihood for change in one bounded context. This AR can be applied if your model exhibits a bounded context with aggregates which have different likelihoods for change.
- The selected bounded context must contain at least two aggregates.
- The aggregates of the selected bounded context must have different likelihoods for change.
- One bounded context.
- Another bounded context containing all the aggregates with the selected volatility.
The following example illustrates how this AR can be applied. The corresponding sources can be found in our examples repository.
The bounded context in this example contains one aggregate which changes OFTEN, whereas the other aggregates have a likelihood for change of NORMAL (default value). The AR is available on the bounded context:
After triggering this refactoring, a dialog pops up on which you can choose by which volatility value you want to extract:
The resulting model contains a new bounded context with the aggregate which is likely to change (OFTEN):
- You can find the CML sources for this AR example here.