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

85 篇文章 0 订阅

问题描述

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

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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

董厂长

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值