Coupling-and-Cohesion
Question 1 |
The coupling between different modules of a software is categorized as follows:
- I. Content coupling
II. Common coupling
III. Control coupling
IV. Stamp coupling
V. Data coupling
Coupling between modules can be ranked in the order of strongest (least desirable) to weakest (most desirable) as follows:
I-II-III-IV-V | |
V-IV-III-II-I | |
I-III-V-II-IV
| |
IV-II-V-III-I |
Question 1 Explanation:
Note: Out of syllabus. [Software Engineering]
Question 2 |
Module design is used to maximize cohesion and minimize coupling. Which of the following is the key to implement this rule?
Inheritance | |
Polymorphism | |
Encapsulation | |
Abstraction |
Question 3 |
In a class definition with 10 methods, to make the class maximally cohesive, number of direct and indirect connections required among the methods are
90, 0 | |
45, 0 | |
10, 10 | |
45, 45 |
Question 3 Explanation:
Methods a and b are related if:
They both access the same class-level variable, or
The call trees starting at a and b access the same class-level variable.
When 2 methods are related this way, we call them directly connected.
When 2 methods are not directly connected, but they are connected via other methods, we call them indirectly connected. Example: A - B - C are direct connections. A is indirectly connected to C (via B).
TCC tells the "connection density", so to speak (while LCC is only affected by whether the methods are connected at all). TCC=LCC=1 is the maximally cohesive class where all methods are directly connected to each other.
Consider a class with N public methods. Let NP be the maximum number of public method pairs : NP = [N * (N – 1)] / 2.
= [10*(9)] / 2
= 90/2
= 45
For Directed Connections:
Let NDC be the number of direct connections between public methods. Then TCC is defined as the relative number of directly connected public methods.
Then, TCC = NDC / NP
NDC =TCC*NP
=45*1
=45
For indirect connections:
Loose Class Cohesion. Let NID be the number of indirect connections between public methods. Then LCC is defined as the relative number of directly or indirectly connected public methods. LCC = NID +NDC/ NP.
1=NID+45/45⇒ NID=0.
They both access the same class-level variable, or
The call trees starting at a and b access the same class-level variable.
When 2 methods are related this way, we call them directly connected.
When 2 methods are not directly connected, but they are connected via other methods, we call them indirectly connected. Example: A - B - C are direct connections. A is indirectly connected to C (via B).
TCC tells the "connection density", so to speak (while LCC is only affected by whether the methods are connected at all). TCC=LCC=1 is the maximally cohesive class where all methods are directly connected to each other.
Consider a class with N public methods. Let NP be the maximum number of public method pairs : NP = [N * (N – 1)] / 2.
= [10*(9)] / 2
= 90/2
= 45
For Directed Connections:
Let NDC be the number of direct connections between public methods. Then TCC is defined as the relative number of directly connected public methods.
Then, TCC = NDC / NP
NDC =TCC*NP
=45*1
=45
For indirect connections:
Loose Class Cohesion. Let NID be the number of indirect connections between public methods. Then LCC is defined as the relative number of directly or indirectly connected public methods. LCC = NID +NDC/ NP.
1=NID+45/45⇒ NID=0.
Question 4 |
Let various levels of cohesion of software modules be denoted by C,T,S, and F as given below:
C: Coincidental F: Functional S: Sequential T: Temporal
Which of the following ordered tuples represents correct ordering from weakest to strongest level of cohesion?
< T,S,C,F > | |
< C,T,S,F > | |
< C,T,F,S > | |
< C,S,F,T > |
Question 5 |
Let various levels of cohesion of software modules be denoted by C,T,S, and F as given below:
C: Coincidental F: Functional S: Sequential T: Temporal
Which of the following ordered tuples represents correct ordering from weakest to strongest level of cohesion?
< T,S,C,F > | |
< C,T,S,F > | |
< C,T,F,S > | |
< C,S,F,T > |
Question 6 |
Most Undesirable Type of Coupling is
Data Coupling
| |
Control Coupling | |
Stamp Coupling
| |
Content Coupling
|