This question will treat software like a tree, where:
- Each node in the tree represents some code unit (eg class \ method \ line etc.)
- Node X is son of Node Y if in the source code X is set in Y
Here is the definition of the term T:
T relative to Node X is the probability that any change on X will result changes 开发者_StackOverflow中文版in nodes that are within the sub-tree of X.
What is the term T? Cohesion or Coupling ?
Coupling would be horizontal, across nodes. Cohesion would be vertical, within the same tree. So T would be cohesion.
Two separate modules, loosely coupled, would be in separate subtrees, and a change in one would not affect the other. But if tightly coupled, a change in one might require a change in the other, even though they are in separate subtrees. Obviously this cannot be what T is.
Cohesion: It is an intra-module concept and indicates relationships within modules.
Coupling: It is an inter-module concept and indicates relationships among modules.
In order to ensure a balanced flexibility and rigidity of any system or software, coupling and cohesion should be balanced.
See this reference for more details.
精彩评论