Purpose of the service layer

后端 未结 3 922
有刺的猬
有刺的猬 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:06

    Traditionally (when not using Domain Driven Design) the service layer, or 'business layer' as it is also called, is where you code all the business logic for your application. So, for example in an application that deals with giving out bank loans, the service layer is where the code goes that decides whether or not a certain loan should be given. Obviously, the service layer would require some information about the applicant of the loan to be able to make a decision on her credibility. To retrieve this information, the business layer calls the 'data' or 'repository' layer, which deals with extracting and storing information into the database.

    The service layer does not deal with matters like persistence or other infrastructural concerns.

    If your design is domain-driven, anthares' answer is true.

提交回复
热议问题