NVS PGT CS 2017 Part-B
April 5, 2024Question 1349 – Engineering-Mathematics
April 7, 2024Software-Engineering
Question 129
|
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 129 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.
Correct Answer: B
Question 129 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.
Subscribe
Login
0 Comments