What to choose?

An effective heuristic to choose which pattern to use for the given subdomain:

  • Track money or monetary transactions? Provide audit log or deep analysis required?Event-sourced domain model. Otherwise…
  • Complex business logic? Domain model. Otherwise…
  • Complex data structures? Active record. Otherwise…
  • Transaction script.

Evaluate business logic complexity

Two heuristics can be used:

  1. Complex business logic includes:
    • business rules,
    • invariants,
    • algorithms. Simple business logic mostly validates the inputs.
  2. If ubiquitous language of the domain mainly describes CRUD operations, then it’s simple. If not describes complicated business processes and rules, then the business logic is complex.