Service Layer Pattern - Could we avoid the service layer on a specific case?

后端 未结 2 1353
滥情空心
滥情空心 2021-02-10 06:23

we are trying to implement an application using the Service Layer Pattern cause our application needs to connect to other multiple applications too, and googling on the web, we

相关标签:
2条回答
  • 2021-02-10 06:51

    "Service Layer" is just an abstraction over your domain logic. The abstraction can be of any degree, including transparent.

    The term layer is misleading. I think Martin himself would agree it is better referred to as a context boundary (from domain driven design). Meaning that you can have many service layers that abstract your domain to different degrees. The service "layer" API that you expose to your UI can do a lot more within your domain than the service layer that you expose to the integration gateway.

    I would recommend breaking up these chunks of services along functional contours though. (For example a set of services that are uses to bulk import data and a set of services that users interact with normally should be almost entirely separate.) This way if you need to expose an API to another application that you expect to interact with you in the exact same way that a user can you have them use the same API that the UI does.

    0 讨论(0)
  • 2021-02-10 07:04

    As mentioned in the link you posted, the service layer defines an "interface" for clients by encapsulating the (complex) business logic and centralizing the control of transaction involving several resources. The service layer is not only used when you need to "share" services, it just makes it easier. But even with a single consumer, centralizing the control of transaction makes sense.

    0 讨论(0)
提交回复
热议问题