开发者

Should services include logged in user as a parameter?

开发者 https://www.devze.com 2023-01-02 23:59 出处:网络
Wh开发者_运维知识库en using the Service design pattern, do you usually place the logged in user, or user scope, as a parameter to the methods of the service interface, or do you call AutheticationServ

Wh开发者_运维知识库en using the Service design pattern, do you usually place the logged in user, or user scope, as a parameter to the methods of the service interface, or do you call AutheticationService.getLoggedInUser() in the service implementation.

What advantages/disadvantages do you find for each option?


Passing the parameter each time makes the service stateless (considering that nothing else is stored on the server). This is good for scalability - having multiple services allows any of them to handle any request.

Having an authentication service makes the calls less complex (and might give you other benefits) but reduces the scalability since the authentication might not be synchronized over all.

0

精彩评论

暂无评论...
验证码 换一张
取 消