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(分层架构)把领域层划分出来。 

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

相关文章

显卡天梯图2024最新版,显卡是电脑进行图形处理的重要设备,...
初始化电脑时出现问题怎么办,可以使用win系统的安装介质,连...
todesk远程开机怎么设置,两台电脑要在同一局域网内,然后需...
油猴谷歌插件怎么安装,可以通过谷歌应用商店进行安装,需要...
虚拟内存这个名词想必很多人都听说过,我们在使用电脑的时候...