SOLID & Design Patterns Interview Question #83

What is the difference between an Application Service and a Domain Service?

DDD Boundaries, Resilience, Caching & Practical ASP.NET Core Design Mid-Level Intermediate

Quick Interview Answer

An Application Service orchestrates a complete application use case and may interact with repositories, transactions, messaging, or authorization. A Domain Service implements business logic that belongs to the domain but does not fit naturally on one entity or value object.

Detailed Explanation

An Application Service orchestrates a complete application use case and may interact with repositories, transactions, messaging, or authorization. A Domain Service implements business logic that belongs to the domain but does not fit naturally on one entity or value object.

Application Services sit around the domain model. Domain Services are part of the domain model and should use domain terminology and rules.

Code Example

// Application service
await orderAppService.ConfirmAsync(orderId);

// Domain service
var price = pricingService.Calculate(
    customer, order, pricingPolicy);