【文章內(nèi)容簡介】
………… B: ………… ………… V2=B1+V1 ………… ………… 問題: ? 公共部分的改動將影響所有調(diào)用它的模塊; ? 公共部分的數(shù)據(jù)存取無法控制; ? 復(fù)雜程度隨耦合模塊的個數(shù)增加而增加。 167。 ?控制耦合 (Control coupling): One module passes parameters to control the activity of another module. A B Flag F2 F1 Fn …… …… Flag 接口單一,但仍然影響被控模塊的內(nèi)部邏輯。 ? 數(shù)據(jù)耦合 (Data coupling): Only data are passed. It is easy to trace data and make changes. ? The most desirable. 原則: 盡量使用數(shù)據(jù)耦合,少用控制耦合,限制公共耦合的范圍,完全不用內(nèi)容耦合。 167。 ? 低內(nèi)聚: ?巧合內(nèi)聚 ( Coincidental cohesion) : Unrelated functions, processes, or data are found in the same module (for convenience). A: Read inputs from disk from tape from …… ? 邏輯內(nèi)聚 ( Logical cohesion): Logically related functions or data are placed in the same module. 例如: ⑵ 內(nèi)聚 (Cohesion): The elements of a module are directed to perform the same task. Goal: as cohesive as possible. 167。 ? 時間內(nèi)聚 ( Temporal cohesion): The functions are related only by the timing involved. 例如:系統(tǒng)的初始化 問題:不同功能混在一個模塊中,有時共用部分編碼,使局部功能的修改牽動全局。 ? 中內(nèi)聚: ? 過程內(nèi)聚 ( Procedural cohesion) : Functions are grouped together in a module to ensure a certain order of performance. 例如: enter data check data manipulate data 167。 ? 通信內(nèi)聚 ( Communicational cohesion) : All the functions in a module operate on or produce the same data set. 例如:從同一磁帶上讀取不相干的數(shù)據(jù) —— 可能破壞獨立性 。 ? 高內(nèi)聚: ? 順序內(nèi)聚 ( Sequential cohesion): The output from one part of a module is the input to the next part. ? 功能內(nèi)聚 ( Functional cohesion): Every processing element is essential to the performance of a single function. 167。 2. 模塊規(guī)模適中: 過大不易理解;太小則接口開銷過大。注意分解后不應(yīng)降低模塊的獨立性。 3. 適當(dāng)控制 —— ? 深度 = 分層的層數(shù)。過大表示分工過細(xì)。 ? 寬度 = 同一層上模塊數(shù)的最大值。過大表示系統(tǒng)復(fù)雜度大。 1. 爭取低耦合、高內(nèi)聚(增加內(nèi)聚 減少耦合) 167。 ? 扇出 = 一個模塊直接調(diào)用 \控制的模塊數(shù)。 3 ? fanout ? 9 A A的扇出