知识卡片
核心类取舍取决于关键场景而非名字
航运教学例中,Customer 看似与“满足客户要求”密切相关;但交付场景直接使用 Customer Agreement 后,通常不必进入 Customer 类,后者也较通用。Leg 则相反:原书作者倾向把它留在核心外,因为它与运输计划、路径服务和地点更内聚;若重要故事频繁涉及 Leg,也可以移入 Delivery,接受拆开旧关系的成本。
这是根据关键场景和概念内聚性做的可调整取舍,不是按“客户”“航段”等业务名词机械划边界。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第15章|Segregated Core · 查看原书依据
And what about pulling Customer out, anyway? The focus is on fulfilling the Customer's requirements, so at first Customer seems to belong in the CORE. Yet the interactions during delivery do not usually need to involve the Customer class now that the Customer Agreement is available directly. And the basic model of a Customer is pretty generic. A strong argument could be made for Leg to remain in the CORE. I tend to be minimalist in the CORE, and the Leg has tighter cohesion with Transport Schedule, Routing Service, and Location, none of which needed to be in the CORE. But if a lot of the stories I wanted to tell about this model involved Legs, I'd move it into the Delivery package and suffer the awkwardness of its separation from those other classes.