首页 > 解决方案 > 在业务逻辑层传递数据

问题描述

我正在使用 JDK 7。

我的所有业务逻辑类都在com.srh.bll.businesslogic包中。

我关心如何将数据从一个业务逻辑类返回到另一个业务逻辑类。

例如,我有 2 个业务逻辑类ReferenceYearBusinessLogicAnniversaryBusinessLogic.

现在methodA需要ReferenceYearBusinessLogic调用methodAAnniversaryBusinessLogic期望得到 3 样东西:referenceDate、 AnniversaryNumber 和 VacationRate。

并且methodC需要ReferenceYearBusinessLogic调用methodBAnniversaryBusinessLogic期望得到两件事:payScale 和 payRate。

等等...

所以我认为在这种情况下我需要定义类来传递数据;一个类有 3 个属性:referenceDate、 AnniversaryNumber 和 VacationRate,而另一个类有 2 个属性:payScale 和 payRate。

在设计模式世界中这些类会被称为什么?我认为它们是 DTO,但 DTO 用于在层之间传输数据,而在我的情况下,它们将仅在一层内使用,并且在该层之外不需要。有什么想法吗?

标签: javadesign-patternsbusiness-logic

解决方案


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.


推荐阅读