SCJP(OCPJP) 考古題解析 第20題

A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?

A. Looser coupling 
B. Tighter coupling 
C. Lower cohesion 
D. Higher cohesion 
E. Weaker encapsulation



答案:AD


解析:

cohesion內聚力、凝聚性的意思

當類別之間互相需要交流的資訊越多

coupling就越高

個好的組織

程式的組織或是社群的組織

要有效的工作

必定是分工十分的恰當

不會做重複的工作

也不會漏掉工作

這就是高度的cohesion



coupling - 對外部的接合、耦合的意思

除了分工恰當之外

個體之間所需的交流越少

就可以降低資訊交換時可能出現的麻煩

或是某個個體被做替換時

需要重新調適的工作

這就是鬆散的coupling

 

一般設計程式時

都會希望程式內部可以有高的cohesion與低的coupling

以增加程式的可讀性與維護性



0 意見:

張貼留言