In Domain-Driven Design (DDD), separating generic subdomains from the core domain is a game-changer. It sharpens focus, reduces complexity, and ensures engineering efforts align with business value.

What Are Generic Subdomains?

These are functionalities that:

  • Solve common problems (e.g., auth, payments, logging).
  • Aren’t competitive differentiators.
  • Can often be outsourced or packaged as internal libraries.

Why Extract Them?

  1. Reduces Complexity – No more tangled core logic with boilerplate code.
  2. Focuses Investment – Engineers spend time on what truly matters.
  3. Improves Maintainability – Changes in generic areas don’t risk core logic.
  4. Enables Faster Iteration – Swap providers or upgrade libraries without refactoring the entire system.
  5. Improving Reusability – You might use them in similar use cases.

How to Do It?

  1. Identify – Separate "must-have" (generic) from "unique" (core).
  2. Decouple – Use self-contained components to isolate generic logic.
  3. Package – Turn reusable components into private packages (or internal libraries).
  4. Define Interfaces – Core domain interacts via contracts, not implementations.

Benefits:

  • Single source of truth
  • Versioned updates
  • No duplication

Pitfalls to Avoid

  • Over-engineering generic parts.
  • Tight coupling between core and generic logic.
  • Ignoring the maintenance costs of tangled and generic logic together.