The following figure represents access graphs of two modules M1 and M2. The…
201320252013
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?

- 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.
Attempted by 28 students.
Show answer & explanation
Correct answer: A
Concept
Module structure is judged by two ratios. Average cohesion = (total intra-module access links, i.e. method-to-attribute edges with both ends inside one module) divided by the number of methods, measuring how self-contained a module is. Coupling = (number of inter-module access links, edges whose two ends sit in different modules) divided by the number of modules, measuring how dependent the modules are. Moving a method can re-classify individual edges as internal or crossing, but a metric changes only if these aggregate counts change.
Application
Read the access graph, then track every count through the move:
Before the move, M1 has 4 methods with 8 intra-M1 links and M2 has 3 methods with 6 intra-M2 links; method m sits in M1 and reaches 2 attributes that live in M2, so those 2 edges cross the boundary (the inter-module links).
Baseline: Cohesion(M1) = 8/4 = 2 and Cohesion(M2) = 6/3 = 2, so average cohesion = 2; Coupling = 2/2 = 1.
Move m into M2. Two things swap at once: m's 2 edges into M2's attributes stop crossing the boundary (they become internal to M2), but m's edges into M1's attributes, which were internal to M1, now cross the boundary from M2 back to M1. The newly-crossing edges replace the ones that stopped crossing, so the inter-module total stays 2.
Recount the methods and links: M1 now has 3 methods with 6 internal links and M2 has 4 methods with 8 internal links.
Recompute: Cohesion(M1) = 6/3 = 2 and Cohesion(M2) = 8/4 = 2, so average cohesion = 2; inter-module links are still 2, so Coupling = 2/2 = 1.
Both the average cohesion (2) and the coupling (1) read exactly as before the move.
Cross-check
Although which specific edges count as crossing does change, the bookkeeping is symmetric: M1 gives up one method and exactly its share of links while M2 takes on the identical method and links, and each boundary edge that stops crossing is matched by one that starts crossing. With both numerators and the per-metric denominators shifting in lock-step, the two ratios are preserved.