Services

Learn what services are in DDD and how they allow us to place logic that does not fit into any entity or value object.

There may be instances where it is required to execute a particular logic. As was previously mentioned, entities and value objects can contain business logic. However, what happens if the particular logic does not fit into any entity or value object? The answer can be found in the functionality of a service.

What are services?

First of all, these objects are called domain services in the context of DDD. Services are objects that implement domain functionality, which cannot be modeled naturally in any entity or value object as part of the domain logic. Domain services are usually implemented when the logic of two or more domain objects is invoked. If service logic needs to interact with an external system, it should be built with the definition of an interface in the domain layer and the implementation of it in another layer.

Get hands-on with 1400+ tech skills courses.