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 |
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 2 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 3 |
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 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 |
Most Undesirable Type of Coupling is
Data Coupling
| |
Control Coupling | |
Stamp Coupling
| |
Content Coupling
|
Question 6 |
Arrange the following types of Cohesion from best to worst type.
A) Logical Cohesion
B) Sequential Cohesion
C) Communication Cohesion
D) Temporal Cohesion
E) Procedural Cohesion
Choose the correct answer from the options given below:
A➡ D➡ E➡ C➡ B | |
A ➡ E ➡D ➡ C ➡ B | |
B ➡ E ➡ C ➡ D ➡ A | |
B ➡ C ➡ E ➡ D ➡ A |
Question 6 Explanation:
➡ Cohesion Cohesion is a measure of the relative functional strength of a module.
➡ Types of cohesion :
➡ Coincidentally cohesive(LOW) a module that performs a set of tasks that relate to each other loosely, if at all. Such modules are termed coincidentally cohesive.
➡ Logically cohesive A module that performs tasks that are related logically (e.g., a module that produces all output regardless of type) is logically cohesive.
➡ Temporal cohesion When a module contains tasks that are related by the fact that all must be executed with the same span of time, the module exhibits temporal cohesion
➡ Procedural cohesion When processing elements of a module are related and must be executed in a specific order, procedural cohesion exists.
➡ Communicational cohesion When all processing elements concentrate on one area of a data structure, communicational cohesion is present.
➡ Sequential Cohesion If the function of the module forms part of sequence, where the output of one function is the input to another function.
➡ Functional Cohesion(HIGH): In this, different elements of the module cooperate with each other to achieve a single function.
➡ Types of cohesion :
➡ Coincidentally cohesive(LOW) a module that performs a set of tasks that relate to each other loosely, if at all. Such modules are termed coincidentally cohesive.
➡ Logically cohesive A module that performs tasks that are related logically (e.g., a module that produces all output regardless of type) is logically cohesive.
➡ Temporal cohesion When a module contains tasks that are related by the fact that all must be executed with the same span of time, the module exhibits temporal cohesion
➡ Procedural cohesion When processing elements of a module are related and must be executed in a specific order, procedural cohesion exists.
➡ Communicational cohesion When all processing elements concentrate on one area of a data structure, communicational cohesion is present.
➡ Sequential Cohesion If the function of the module forms part of sequence, where the output of one function is the input to another function.
➡ Functional Cohesion(HIGH): In this, different elements of the module cooperate with each other to achieve a single function.