2

As what I read from some articles on Domain Driven Design, the Domain Services are to ensure the logical integrity of the domain and may call other domain services for external things.

So, can I assume that, in a web application of separated front end and back end, even if the client side is not believable, as long as Domain Services can ensure that no business rule would be broken, I can put all Application Services to the front end?

If the answer is yes, is it reasonable that putting all Application Services to the front end would help reduce the load of the server and simplify the hierarchy (since the front end itself needs a service layer) for there would be no Application Service layer in the server side? Would there be security problems?

Alsein
  • 4,268
  • 1
  • 15
  • 35

1 Answers1

0

You can and you should keep the application layer as thin as possible and prevent any leaks of the domain model to the application layer. But I don't think that you can remove the application layer from the backend completly, because you need to have at least some persistence logic in there.

Roman Weis
  • 347
  • 3
  • 8
  • Is persistance logic supposed to be in the application layer? I am new to ddd and pretty much confused with the implementation details. – Alsein Mar 09 '19 at 10:09
  • Yes, all infrastructure concerns like persistence should be outside of the domain layer, which is the application layer. – Roman Weis Mar 09 '19 at 10:41
  • According to these articles https://www.thereformedprogrammer.net/three-approaches-to-domain-driven-design-with-entity-framework-core/ https://www.thereformedprogrammer.net/is-the-repository-pattern-useful-with-entity-framework-core/ , there is no need for repository layer, for the persistance logic could be handled by the domain models themselves. – Alsein Mar 10 '19 at 03:22
  • @Alsein the article has an exception point of view. But most of reference books in DDD like "Patterns, Principles and Practices of Domain-Driven Design" strongly recommend not do this, because it violates the principles of DDD. Domain Model just handles the domain logic and is the implementation of the UL. There should not be any technical issue inside it. If you remove repository layer, you will insert the persistence logic inside the domain layer which makes your backend less maintainable. – Code Pope Dec 06 '20 at 19:36