Purpose of the service layer

后端 未结 3 920
有刺的猬
有刺的猬 2021-01-31 05:20

Am I correct in thinking that the purpose of a service layer includes the following?

  • thinning out of domain models (i.e. movement of certain functions like in cach
3条回答
  •  被撕碎了的回忆
    2021-01-31 06:00

    In terms of domain-driven design for example the domain service layer is used for operations that cannot be defined in the context of you Domain objects. For example if you have an object CreditCard, a suitable operation in your service layer would be Issue a new Credit Card.

    In bigger application is used the pattern Anemic Domain Models, where the domain objects are used only as data containers and the whole business logic is in your domain service layer (this is sometimes refered as anti-pattern, but may be very useful in big solution, with adding another abstraction layer).

    In difference solution architectures and patterns, service layer may have difference purpose, though.

提交回复
热议问题