Services

Learn what service in Domain Driven Design is and how they allow placing 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 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 is a service.

What are services?

First of all, these objects are called domain services in the context of Domain Driven Design. They are objects that implement domain functionality that cannot be modeled naturally in any entity or value object as part of the domain logic. Domain services are usually implemented by invoking the logic of two or more domain objects. If service logic needs to interact with an external system, it should be built by defining an interface in the domain layer and implementing it in another layer.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy