23

I'm struggling a little bit with Domain Driven Design because there are so many names and concepts to grasp.

Today it striked me to know what is exactly the difference between an 'application service' and an 'use case'. Are they the same thing?

  • 4
    Unless DDD has a really weird use for the term "use case", then they are not the same thing. Use case is a common term for a functional requirement of the app, whereas an application service is a piece of code that coordinates interactions between stuff like value objects, entities and domain services. – David Arno Feb 19 '18 at 12:18
  • 9
    Alghough DDD and Uncle Bobs Clean Architecture focus on different things, if you are comparing the two, I'd say that application services in DDD roughly correspond to the application business rules layer in CA, which implements use cases (or user stories - at that level in the architecture, the distinction doesn't really matter). Also, the DDD terminology is trying to make a distinction between application services which depend on the domain layer, and domain services, which take part in implementing the domain logic. – Filip Milovanović Feb 19 '18 at 12:52

2 Answers2

24

In Clean Architecture jargon, use cases are indeed similar to DDD Application Services. In UML though, use cases refer to broader business scenarios rather than a technical layer.

guillaume31
  • 8,593
8

No, they are not the same thing. Use case is a meaningful operation performed by your application. As a part of it, it can call other sub-operations in other bounded contexts. That sub-operations are implemented as application services in monolithic applications and are meaningful only as a part of a use case. Those are good candidates for becoming microservices in the microservice architecture. The use case, in turn, becomes a separate microservice calling these microservices.

Example: you create a booking via REST. The controller gathers the input and invokes a "reserveRoom" use case in Booking bounded context. The use case, in turn, calls the AvailabilityService in Availability bounded context to decrement the number of available rooms and PaymentService to check the validity of the credit card.

raiks
  • 183