知识卡片
基础设施约束不应改写领域含义
领域上,Fee Entry 与 Interest Entry 若没有不同的行为或概念规则,只需落在各自 Account;Payment 与 Accrual 因职责不同才值得分成子类。原书的大体虚构案例却给出一项实现妥协:关系表必须脱离程序可读,而所用 ORM 只能靠具体子类把费用和利息条目写入不同表,于是图11.7出现 Fee Payment、Interest Payment 等额外子类。
这些子类属于特定基础设施强制的表示,不应倒过来声称费用与利息条目在领域上本来不同。记录妥协及其原因,后续换基础设施时才可重新评估。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第11章|Example Earning Interest with Accounts · 查看原书依据
This meant keeping fee entries and interest entries in separate tables. The only way for developers to do this, using their particular object-relational mapping framework, was to make concrete subclasses (Fee Payments, Interest Payments, and so on). With different infrastructure, they might have avoided this clumsy expansion.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第84章《Example Earning Interest with Accounts》(源文件:_epub-src/0321125215_ch11lev2sec1.html;单元02)
- 结论依据:原文先说费用/利息来源的 Entry 无概念或行为差异,再说明项目所用关系表和ORM迫使增加具体子类,并明确这是现实约束而非领域发现。
- 原始内容:This meant keeping fee entries and interest entries in separate tables. The only way for developers to do this, using their particular object-relational mapping framework, was to make concrete subclasses ( Fee Payments, Interest Payments , and so on). With different infrastructure, they might have avoided this clumsy expansion.