Machine-translated by Google. Questions are authored in English.
Top

Discussion

The following figure represents access graphs of two modules M1 and M2. The filled circles represent methods and the unfilled circles represent attributes. If method m is moved to module M2 keeping the attributes where they are, what can we say about the average cohesion and coupling between modules in the system of two modules ?

Access graphs of two modules. Module M1 has four methods and four attributes, each method with arrows to two of them; the method m has two further arrows to attributes of Module M2. Module M2 has three methods and four attributes, each method with arrows to two attributes.

  • A.There is no change
  • B.Average cohesion goes up but coupling is reduced
  • C.Average cohesion goes down and coupling also reduces
  • D.Average cohesion and coupling increase.

Answer: A

The correct choice is There is no change.

Read the figure as a bipartite graph of methods and the attributes they access. Module M1 has 4 methods, 4 attributes and 8 arrows inside it, plus 2 arrows from method m into M2's attributes. Module M2 has 3 methods, 4 attributes and 6 arrows inside it. Measure cohesion as the fraction of possible method-to-attribute links that exist inside the module:

\[ \begin{aligned} \text{before, } M1 &= \tfrac{8}{4 \times 4} = 0.5 \\ \text{before, } M2 &= \tfrac{6}{3 \times 4} = 0.5 \end{aligned} \]

Move m to M2. Its 2 arrows into M2's attributes become internal and its 2 arrows into M1's attributes now cross the boundary:

\[ \begin{aligned} \text{after, } M1 &= \tfrac{6}{3 \times 4} = 0.5 \\ \text{after, } M2 &= \tfrac{8}{4 \times 4} = 0.5 \end{aligned} \]

Coupling is the number of arrows that cross between the modules: 2 before and 2 after. Both cohesion figures and the coupling are unchanged, so the other three options, which claim a change, are wrong.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.