知识卡片
计提与付款按概念分合
原书的贷款跟踪教学案例中,旧模型用 Fee Calculator、Interest Calculator 分别计算,并保存两套 Payment History。重构把不同计提日程拆成 Accrual Schedule 子类,却把费用和利息的付款合成一个 Payment 概念:差异留在日程,公共规则落在付款。
图10.12示意新增 Annual Fee 日程时扩展对应子类;后来出现提前或逾期付款规则,案例中的相同规则可连接统一的 Payment,避免在两套付款历史中重复。这里是书中的设计推演,不是生产验证,也不保证所有未知变化都容易处理。
结构图:
classDiagram
class Asset
class AccrualSchedule {
+accrualsForDateRange()
}
class DailyCompoundInterest
class MonthlyFee
class AnnualFee
class Payment
Asset --> AccrualSchedule : 持有日程
Asset --> Payment : 记录付款
AccrualSchedule <|-- DailyCompoundInterest
AccrualSchedule <|-- MonthlyFee
AccrualSchedule <|-- AnnualFee
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第10章|Conceptual Contours · 查看原书依据
Schedules, which had been worked out through case logic in the Calculator classes, were exploded into discrete classes for different types of fees and interest. On the other hand, payments of fees and interest, previously kept separate, were lumped together. Because of the resonance of the newly explicit concepts and the cohesiveness of the Accrual Schedule hierarchy, the developer believed that this model better follows some of the domain's CONCEPTUAL CONTOURS.