18

I don't really understand the difference between a Use Case Interactor and a Service in Clean Architecture. Is a domain service just a collection of "Use Case Interactor methods"?

I want to implement the clean architecture in my ASP.net Core Application, but i am not sure if I should implement it in the "Use Case Interactor" way (https://fullstackmark.com/post/18/building-aspnet-core-web-apis-with-clean-architecture), the "Service" way (https://github.com/ardalis/CleanArchitecture) or if I should combine them (if possible at all).

Christoph Hummler
  • 971
  • 2
  • 7
  • 20
  • 2
    In terms of DDD there are few types of services. And layers. There are domain layer which responsible for business logic, and domain services, also responsible for manipulating business rules and entities. The application service implement use cases.And application service implements use cases and works close with domain services. The other part of software , like infrastructure layer , work with your app service. – grinay Aug 14 '19 at 10:43
  • Is this related: [Service Layer](https://martinfowler.com/eaaCatalog/serviceLayer.html) – Mahozad Jun 10 '22 at 10:09

1 Answers1

13

Strictly speaking, the term "Domain Service" does not exist in Uncle Bob's Clean Architecture but in DDD. In Clean Architecture all business logic goes to Use Case Interactors and Entities. So if you want to strictly follow Uncle Bob's architecture, follow the Use Case Interactors way described in the first article you linked.

For a more detailed discussion on use cases and use case Interactors pls refer to my post: http://www.plainionist.net/Implementing-Clean-Architecture-UseCases/

plainionist
  • 2,950
  • 1
  • 15
  • 27
  • Oh, you took a really interesting approach. What do you think about the idea, to only have one interactor per use case, which uses services. Because in my mind a use case interactor is something different than a service. A use case interactor handles the process to fulfill the use case and a service is resonsible for fulfilling a simple task, independet which interactor called it. I saw you created multiple interactors for a use case (indeed the difference between my 'service' and your 'sub-interactors' is just the name). Do you think that my approach also fulfils the claims of CA? – Christoph Hummler Aug 15 '19 at 10:58
  • As you already pointed out: the difference is just the name ;-) so if you want to give classes fulfilling a simple task a different name: go ahead. I think it is still in line with clean architecture. You just might consider putting some of your service functionality into entities if it is about core business logic which is not use case and application specific. – plainionist Aug 17 '19 at 05:10
  • 2
    Ok, thanks for the hint to put some service functionality into entities. This is a good advice. – Christoph Hummler Aug 17 '19 at 13:07