微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ABP:是否应该在一个应用服务中调用另外一个应用服务?

问题描述

在改bug过程中,我发现我需要在创建用户函数调用另外一处application service下的函数

相当于我想在一个应用服务中调用另外一个应用服务。


分析:

网上找到的回答:

I don't suggest to call an application service from another service in the same domain. Application services are designed to be called from UI layer. It implements audit logging, authorization, validation... and they will not probably needed if you use a code in the same application layer.

An application service method is a public endpoint of your application. Calling an application service from another is like going out of your application and entering from a different point. You also probably don't want to change an application service method if another application service method's signature changes (because of a requirement change in UI).

My suggestion is to seperate the shared code into another class (probably a domain service) and use from both application services.

简单来说:

不要再一个应用服务内调用另外一个应用服务。应用服务层是程序的公共端点。不要在这层相互间调用,会引起结构混乱。

建议是将多个领域服务共同用到的部分单独抽离到一个类里面。通常来说,在ABP里面,就是下沉到领域服务层domain。

那么打开《领域驱动设计》,看一下一个重要的概念:隔离领域

未来防止领域的职责与系统的其他部分混在一起,我们应该应用layered Architecture(分层架构)把领域层划分出来。 

简单理解:一个入口不应该通向另外一个入口。

原文地址:https://www.jb51.cc/wenti/3285884.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐