Domain-Driven Design (50 Qs)•Part 3: Advanced Architecture & Production Patterns (Senior / Lead)
Domain Services vs Application Services.
senior LevelSystem Design
In Simple Words:
- Domain Service: Holds pure business logic that does not naturally belong to a single Entity or spans multiple Aggregate Roots (e.g.
TransferFundsServicechecking limits across two accounts, or calculating currency conversion rates). Zero I/O, zero database queries, zero HTTP calls! - Application Service (Use Case Orchestrator): The outer boundary coordinator:
- Opens database transaction.
- Loads Aggregate from Repository.
- Invokes Domain methods.
- Persists Aggregate and publishes Domain Events.
- Handles security authorization and logging.