← 返回刚才阅读的位置

知识卡片

结构图卡 · 1831.a.2.b

最少知识原则重新分配耦合

理解等级:高级

最少知识原则让组件只知道完成自身职责所需的邻居。原书订单例子中,下单组件必须通知库存扣减;但“库存过低后补货并调价”可由库存组件决定,减少下单组件对供货和定价组件的了解。这样通常是把耦合移到更合适的位置,并不保证全系统依赖总量下降。

结构图:

flowchart LR
  A[下单组件] --> B[库存组件]
  B --> C[补货组件]
  B --> D[定价组件]
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Fundamentals of Software Architecture》第10章《Component-Based Thinking》(源文件:`OEBPS/ch08.html`) - 结论依据:原文图8-14和8-15对照重分配后的调用关系,并明确总耦合未必下降。 - 原始内容:Applying the Law of Demeter does not necessarily reduce the system-wide level of coupling; rather, it usually redistributes that coupling to different parts of the system .