← 返回刚才阅读的位置

知识卡片

结构图卡 · 1971.o.1.c.1.a.1.d.2

计提与付款按概念分合

理解等级:高级

原书的贷款跟踪教学案例中,旧模型用 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
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 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.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第76章《Conceptual Contours》(源文件:_epub-src/0321125215_ch10lev1sec4.html;单元02) - 结论依据:原文和图10.11–10.13显示计提日程被拆分、付款被合并;随后案例中的早/晚付规则适用两类付款,显示该边界对这次未预见需求有利。 - 原始内容: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 .