java - 在业务逻辑层传递数据
问题描述
我正在使用 JDK 7。
我的所有业务逻辑类都在com.srh.bll.businesslogic
包中。
我关心如何将数据从一个业务逻辑类返回到另一个业务逻辑类。
例如,我有 2 个业务逻辑类ReferenceYearBusinessLogic
和AnniversaryBusinessLogic
.
现在methodA
需要ReferenceYearBusinessLogic
调用methodA
并AnniversaryBusinessLogic
期望得到 3 样东西:referenceDate、 AnniversaryNumber 和 VacationRate。
并且methodC
需要ReferenceYearBusinessLogic
调用methodB
并AnniversaryBusinessLogic
期望得到两件事:payScale 和 payRate。
等等...
所以我认为在这种情况下我需要定义类来传递数据;一个类有 3 个属性:referenceDate、 AnniversaryNumber 和 VacationRate,而另一个类有 2 个属性:payScale 和 payRate。
在设计模式世界中这些类会被称为什么?我认为它们是 DTO,但 DTO 用于在层之间传输数据,而在我的情况下,它们将仅在一层内使用,并且在该层之外不需要。有什么想法吗?
解决方案
writing code is all about imagination . somethign that is easier to read , very simple , performant and easily testable. if I were in this situation probabley might create a domain class to bundle these parametrrs {referenceDate, anniversaryNumber and vacationRate} and another class for payScale and payRate. these classess maynot be end with DTO naming convention.
推荐阅读
- node.js - 适用于 postgreSQL 的 AWS Lambda 函数 NodeJs - 超时错误
- windows - 删除具有特定扩展名的文件(特定文件除外)
- oop - Monolith,洋葱架构,多种数据库类型,如何从具有不同数据库类型的 2 个不同服务类中进行“事务”?
- sql - 将 nvarchar(255) 转换为日期 SQL
- javascript - 为什么这个函数会抛出无法捕获的异常?
- python - 为什么 os.system('cls') 打印 0
- c++ - 如何删除冗余输入?
- ios - 旋转 ARKIT 模型
- node.js - FaunaDB 中的“由于检测到并发修改而中止事务”
- javascript - 我有一个 AJAX 发布请求,我的 spring 控制器应该如何