SOLID & Design Patterns Interview Question #82
What is an Application Service in a DDD-style architecture?
DDD Boundaries, Resilience, Caching & Practical ASP.NET Core Design Mid-Level Intermediate
Quick Interview Answer
An Application Service coordinates a use case. It loads domain objects, invokes domain behavior, calls required collaborators, and persists the resulting changes.
Detailed Explanation
An Application Service coordinates a use case. It loads domain objects, invokes domain behavior, calls required collaborators, and persists the resulting changes.
Application Services should generally avoid containing core business rules that belong in entities, value objects, or domain services. Their role is orchestration across application and domain boundaries.
Code Example
public async Task ConfirmOrderAsync(Guid orderId)
{
var order = await _orders.GetByIdAsync(orderId)
?? throw new NotFoundException();
order.Confirm();
await _unitOfWork.SaveChangesAsync();
}