DDD journey: what's the difference between domain and application services?

Posted on April 8, 2021


In the series of my short DDD journey articles, I’ll summarize some of the insights that came out speaking with the author of the Advanced Web Application Architecture book.

Thanks to the author, you can get it with a special discount reserved to the readers of this blog!

Domain and application services

Before going through the difference between domain and application services, let’s see where they live inside our target architecture, looking at a picture that hopefully explains everything.

The picture that (hopefully) explains everythhing

Both applications and domain services belong to our application’s core layer, so it’s clear that they are not part of the infrastructure layer.

I will not dwell on the importance of decoupling from infrastructure, Noback dedicates an entire chapter of his book to this topic, and I warmly recommend reading it. You can also refer to this excerpt that contains a couple of sections from the conclusion of the chapter.

I go straight to the point of my question: what is the difference between domain and application services?

We can think of application services as use cases, e.g., order an ebook or give me the list of available ebooks.

These services are available to consumers of our application that live in the infrastructure layer. To make an example, a web controller is a consumer of our application services.

On the other hand, domain services can be considered implementation details, e.g., calculate the order total, and are mainly used inside the domain and not exposed to the application’s consumers.

Closing remarks

We should never directly expose a domain service to infrastructure.

If an application’s consumer needs to access a domain service, we should proxy it through an application service.


Posted with : ddd