Search code examples
c#domain-driven-designn-layerapplication-layer

Does application services belong to domain layer or application layer?


I have a N-Layered Winforms application with 4 layers as follows:

Presentation Layer

Application Layer

Domain Layer

Infrastructure Layer

My Application Layer has a Product Services class which is used for all repository related actions for Products.

Does the interface file for the Product Services class belong in the Application Layer or Domain Layer? I ask because the interface file for my repositories is defined in the Domain Layer even though they are implemented in the Infrastructure Layer.

Thanks in advance.


Solution

  • Service concept can belong to any layer. If you ask for application services, then these should live in the application layer.

    In the other hand, if these services are the ones directly accessing the domain, then they're still domain. That is, I would expect to find both a service interface and one or more implementations in any project prefixed with Domain.

    BTW, the project has nothing to do with software layers. It's just an organizational unit to group files by some criteria. The most important point is your flow should work with inversion of control in mind to glue layers.