fbpx

系統設計 - 內聚力(Cohesion)與耦合力(Coupling)

內聚力(Cohesion)與耦合力(Coupling)為 Edward Yourdon and Larry L. Constantine. 在 1979 年 Structured Design: Fundamentals of a Discipline of Computer Program and System Design 一書中所提出的種系統衡量方式,至今已經成為系統設計上不可或缺的重要概念。書中提及:

Obviously, what we are striving for is loosely coupled systems --- that is, systems in which one can study (or debug, or maintain) any one module without having to know very much about any other modules in the system.

The most effectively modular system is the one for which the sum of functional relatedness between pairs of elements not in the same module is minimized; among other things, this tends to minimize the required number of intermodular connections and the amount of intermodular coupling.

因此對於一個系統(或模組)而言,內聚力(Cohesion)應越高越好,而耦合力(Coupling)應越低越好

其作者將內聚力(Cohesion)分為以下七種,由高至低分別為:

  • 功能內聚力 (Functional Cohesion)
  • 循序內聚力 (Sequential Cohesion)
  • 溝通內聚力 (Communication Cohesion)
  • 程序內聚力 (Procedural Cohesion)
  • 暫時內聚力 (Temporal Cohesion)
  • 邏輯內聚力 (Logical Cohesion)
  • 偶發內聚力 (Coincidental Cohesion)

而耦合力(Coupling)為:

  • 資料耦合力 (Data Coupling)
  • 資料結構耦合力 (Stamp/Data-structure Coupling)
  • 控制耦合力 (Control Coupling)
  • 共同耦合力 (Common/Global-data Coupling)
  • 內容耦合力 (Content/Pathological Coupling)

內聚力(Cohesion)與耦合力(Coupling)似乎已經是個系統設計的必考題,也是很基本的概念。但是在實際在系統設計上卻常被遺忘與忽略,如果在設計複雜與高度擴充的系統時,保持這樣的理念將會提高系統的維護與重用性 (Reusable)。這個原則是相當重要的參考依據,身為系統設計與開發人員,銘記在心是必要的。

參考資料:

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料