Services and modules
In DDD, services and modules play a pivotal role in maintaining the clarity and separation of concerns within your application. Understanding the distinction between domain services and application services is crucial for architecting a robust and maintainable system.
Let’s start with services and see what the two types of service are, the differences between them, and when to use them. As usual, this exploration will be illustrated by examples in the domain of our brewery ERP.
Domain services
Domain services are an integral part of the domain model, encapsulating business logic that doesn’t naturally fit within an aggregate. They are used when a particular operation or process spans multiple entities or when the behavior does not belong to any specific entity. Domain services are pure, meaning they do not have side effects and typically do not rely on external systems such as databases or messaging systems.
Consider the brewery ERP...