TLDR: not quite sure whether I got my Bounded Context right.
I have a domain model in one Bounded Context:
Entire model is in the same bounded context. Bounded context has two responsibilities:
- administering products/rules/parameters
- parsing/executing products' rules
Business invariants pertaining to administering products, rules and parameters are contained within the aggregates themselves. The existing Product/Rule/Parameter model is very suitable for this.
Problems arise when executing rules. In order to execute a (set of) rules, I need to fiddle around a lot, query and filter across multiple collections:
- A specific Product
- All of the Rules belonging to that Product
- All of the Parameters belonging to those Rules.
- Sometimes I even need to filter across those collections for very specific combinations and this is getting more and more cumbersome.
So I created a new class
ExecutionProduct as a placeholder for all the filtered data needed by the
ExecutionRule + started adding filtering logic to
ExecutionProduct. It is not a perfect fit for the execution model + there is a lot extraneous data within the aggregates, but I can manage.
ExecutionProduct got me thinking whether I should move parsing/executing responsibilities into a standalone Bounded Context, since that would allow me to morph existing data into more suitable format for execution. Please note that when executing rules, there is no need to persist anything: it consist of running through all the rules and doing complicated filtering, comparison and other business logic.