知识卡片
组织图后来收回机制仍保留声明式接口
原书组织图项目完成约一年后,其他开发者认为独立图框架带来的对象数和包分隔不合算,把节点行为并入组织实体的父类。实际重构结果仍保留组织模型的声明式公开接口,机制也继续封装在实体内部。
所以“分离后又合回去”不等于回到原点:中间阶段帮助团队识别事实、目标与机制,后来可删去多余结构,同时留下清晰接口与封装。是否保持单独框架取决于当时的复杂度收益。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第15章|Cohesive Mechanisms · 查看原书依据
Actually, a year after we completed the organization model in the previous example, other developers redesigned it to eliminate the separation of the graph framework. They felt the increased object count and the complication of separating the MECHANISM into a separate package were not warranted. Instead, they added node behavior to the parent class of the organizational ENTITIES. Still, they retained the declarative public interface of the organization model. They even kept the MECHANISM encapsulated, within the organizational ENTITIES. These full circles are common, but they do not return to their starting point. The end result is usually a deeper model that more clearly differentiates facts, goals, and MECHANISMS. Pragmatic refactoring retains the important virtues of the intermediate stages while shedding the unneeded complications.