知识卡片
隐性概念同样形成依赖
类的依赖不只来自字段类型、参数、返回值和关联;原始值背后的领域含义也会增加理解负担。比如三个 int 字段表示颜料的红、黄、蓝分量时,颜色概念已经存在,把它命名为 Pigment Color 并未凭空增添概念,只是让原有依赖显式可见。反过来,集合 size() 返回的整数仅表示计数,通常不引入新的领域概念。
审视耦合时要追问“理解此类还需知道哪个领域概念”,不能只数代码中的类型引用。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第10章|Standalone Classes · 查看原书依据
Implicit concepts, recognized or unrecognized, count just as much as explicit references. Although we can generally ignore dependencies on primitive values such as integers and strings, we can't ignore what they represent. For example, in the first paint mixing examples, the Paint object held three public integers representing red, yellow, and blue color values. The creation of the Pigment Color object did not increase the number of concepts involved or the dependencies.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第77章《Standalone Classes》(源文件:_epub-src/0321125215_ch10lev1sec5.html;单元01)
- 结论依据:原文明确说隐性概念与显式引用都算依赖,并用颜料分量与集合大小对比领域含义是否另成概念。
- 原始内容:Implicit concepts, recognized or unrecognized, count just as much as explicit references. Although we can generally ignore dependencies on primitive values such as integers and strings, we can't ignore what they represent . For example, in the first paint mixing examples, the Paint object held three public integers representing red, yellow, and blue color values. The creation of the Pigment Color object did not increase the number of concepts involved or the dependencies.