Why Cohesion Has No Scalar Metric

Design dashboards like one number per module. Complexity, coupling, cohesion — a single score, a colour, a flag. This page shows why, for cohesion, one number cannot decide whether an element is well placed. The failure is not a matter of precision or of a poorly chosen formula. It is structural, and it has four independent causes.

A module can deviate from its rule in two opposite ways — it can hold elements that do not belong, or it can be missing elements that do. These two defects call for opposite repairs, and no single number can tell them apart. The rest of this page proves that claim and its companions.

1 The setting

Cohesion is correctness relative to a partitioning rule [1]. A rule PP sorts the element set EE into equivalence classes [e]P[e]_P — the elements that belong together. A module M⊆EM \subseteq E complies when its boundary coincides with its class: M=[e]PM = [e]_P for every e∈Me \in M. Otherwise it deviates in one of two ways:

  • Impurity. MM contains elements from another class. The remedy is to remove them — to split.
  • Incompleteness. Some element of the module’s class lies outside MM. The remedy is to add it — to merge.

Assess a module MM against a class CC (the class it should realize). Write

purity(M)=|M∩C||M|,completeness(M)=|M∩C||C|. \text{purity}(M) = \frac{|M \cap C|}{|M|}, \qquad \text{completeness}(M) = \frac{|M \cap C|}{|C|}.

Both values lie in [0,1][0,1]. Purity is 11 exactly when MM has no foreign element; completeness is 11 exactly when MM is missing no member of CC. A module is fully cohesive precisely when both are 11.

The question of this page: can a single real number s(M)s(M) stand in for this pair and decide placement — issue the statement “this element is incorrectly placed”?

Two notions make the question precise.

Principled scalar. A function s(e,M,ℳ,E,R,P)→ℝs(e, M, \mathcal{M}, E, R, P) \to \mathbb{R} that may consult the principle PP as well as the structure — but whose output is one real number.

Verdict-deciding. ss decides placement iff there is an interpretation d:ℝ→{correct,incorrect}d: \mathbb{R} \to \{\text{correct}, \text{incorrect}\} with d(s(e,M))=VP(e,M)d(s(e,M)) = V_P(e,M) for every system and every element-module pair. (The module-level form s(M)s(M) is read the same way; the verdict is uniform across a module, so s(M)s(M) assigns one verdict to every element of MM.)

Four failure modes follow. They run from the strongest restriction on the metric — it cannot even see the rule — to the weakest — it sees everything and still adds nothing.

2 Failure mode 1 — the metric cannot see the rule

Suppose the number is computed from the structure alone: from EE, RR, and the module MM, with no access to PP. Then it cannot decide placement, whatever its formula and whatever its precision.

Example. Let E={a,b}E = \{a, b\} and R=∅R = \emptyset, and let the module under test be M={a}M = \{a\}.

  • Under P1P_1 with a single class {a,b}\{a, b\}, we have [a]P1={a,b}≠M[a]_{P_1} = \{a,b\} \neq M, so aa is incorrectly placed (the module is missing bb).
  • Under P2P_2 with classes {a},{b}\{a\}, \{b\}, we have [a]P2={a}=M[a]_{P_2} = \{a\} = M, so aa is correctly placed.

The two systems present identical structural inputs — same EE, same RR, same MM — to any structural function, so such a function returns the same number for both. Yet the verdicts differ. No formula over the structure alone can be correct on both, at any level of precision.

This is the principle-blindness obstruction: the structure (E,R)(E,R) underdetermines PP, so “correct” — which is meaningless without PP — cannot be read off it. The constructive cell is also visible: give the metric access to PP and it can compare MM with [e]P[e]_P. But access alone is not enough, as the next three results show.

3 Failure mode 2 — one axis collapses two opposite defects

Grant the metric full access to PP, but let it return one number per module, built from the two-axis pair: s(M)=g(purity(M),completeness(M))s(M) = g(\text{purity}(M), \text{completeness}(M)) for some g:[0,1]2→ℝg: [0,1]^2 \to \mathbb{R}.

Proposition (aggregation ambiguity). (a) If gg is symmetric — g(p,c)=g(c,p)g(p,c) = g(c,p) — there are two modules with opposite defects and opposite remedies whose scores are exactly equal. (b) If gg is continuous and strictly increasing in each argument, the two classes of defect are indistinguishable to any measurement precision, and no threshold on the score separates them.

Proof. Fix a rule PP with a class CC of size 44, and four foreign elements x1,…,x4x_1, \dots, x_4 all belonging to another class.

  • Let M1=C∪{x1,x2,x3,x4}M_1 = C \cup \{x_1, x_2, x_3, x_4\}, so |M1|=8|M_1| = 8. Then purity(M1)=4/8=1/2\text{purity}(M_1) = 4/8 = 1/2 and completeness(M1)=4/4=1\text{completeness}(M_1) = 4/4 = 1: impure but complete — the remedy is to remove the four foreign elements.
  • Let M2={a,b}M_2 = \{a, b\} for two elements a,b∈Ca, b \in C. Then purity(M2)=2/2=1\text{purity}(M_2) = 2/2 = 1 and completeness(M2)=2/4=1/2\text{completeness}(M_2) = 2/4 = 1/2: pure but incomplete — the remedy is to add the two missing members.

Both modules can be realized in one system (E,R,P)(E, R, P).

(a) By symmetry, s(M1)=g(1/2,1)=g(1,1/2)=s(M2)s(M_1) = g(1/2, 1) = g(1, 1/2) = s(M_2): the scores coincide exactly, while the defects and the required repairs are opposite. The geometric mean g(p,c)=pcg(p,c) = \sqrt{pc} scores both modules at 1/21/\sqrt{2}.

(b) Consider the two boundary curves B1={(p,1):0<p<1}B_1 = \{(p, 1) : 0 < p < 1\} (impure-but-complete) and B2={(1,c):0<c<1}B_2 = \{(1, c) : 0 < c < 1\} (pure-but-incomplete). Because gg is strictly increasing, g(1,1)g(1,1) is the supremum of gg on both curves; because gg is continuous, each image g(B1)g(B_1), g(B2)g(B_2) is an interval with that same supremum. Two intervals with a common supremum overlap: there exist (p*,1)∈B1(p^*, 1) \in B_1 and (1,c*)∈B2(1, c^*) \in B_2 with g(p*,1)=g(1,c*)g(p^*, 1) = g(1, c^*). So an impure-but-complete module and a pure-but-incomplete module share the same score, and in their neighbourhood the two classes of module are indistinguishable to any finite precision. An interpretation that reads the failure mode off intervals of the score line therefore misclassifies achievable modules — there is no threshold that separates “remove foreign elements” from “add missing members.” ◼\blacksquare

The single number says something is wrong. It cannot say what, and the two repairs point in opposite directions.

4 Failure mode 3 — a number cannot name the element

Even a scalar that could read the defect from the score still could not say which element to move. Suppose ss is name-invariant: renaming the elements — carrying one system to another by a bijection σ\sigma with R′=σ(R)R' = \sigma(R), P′=σ∘P∘σ−1P' = \sigma \circ P \circ \sigma^{-1}, ℳ′=σ(ℳ)\mathcal{M}' = \sigma(\mathcal{M}) — leaves the score unchanged, sS′(σ(M))=sS(M)s_{S'}(\sigma(M)) = s_S(M). Any function deserving the name “measurement of the configuration” is name-invariant.

Proposition (no localization). A name-invariant module-level scalar cannot identify the repair target. There are two systems with the same element set, the same module MM, and the same score, whose minimal repairs move different elements.

Proof. Let E={a,b,c,x}E = \{a, b, c, x\}, let R=∅R = \emptyset, and let M={a,b,x}M = \{a, b, x\}.

  • System 1. P1P_1 induces classes {a,b}\{a, b\} and {c,x}\{c, x\}. Then MM is not a P1P_1-class, and the unique one-move repair is to remove xx: M\{x}={a,b}M \setminus \{x\} = \{a, b\} is a P1P_1-class, while no other single move produces one.
  • System 2. P2P_2 induces classes {a,x}\{a, x\} and {c,b}\{c, b\}. Again MM is not a class, and the unique one-move repair is to remove bb: M\{b}={a,x}M \setminus \{b\} = \{a, x\}.

Now take the transposition σ=(bx)\sigma = (b\ x), which exchanges bb and xx and fixes aa and cc. It carries system 1 to system 2: σ({a,b})={a,x}\sigma(\{a,b\}) = \{a,x\}, σ({c,x})={c,b}\sigma(\{c,x\}) = \{c,b\}, σ(R)=R\sigma(R) = R, and σ(M)=M\sigma(M) = M (the set {a,b,x}\{a,b,x\} is fixed as a set).

By name-invariance, sS2(M)=sS2(σ(M))=sS1(M)s_{S_2}(M) = s_{S_2}(\sigma(M)) = s_{S_1}(M): the score is the same in both systems. But the repair targets differ — xx in system 1, bb in system 2. A designer observing only the score cannot tell the two configurations apart. And the obstruction is structural, not a matter of resolution: a score fine-grained enough to point at xx rather than bb would have to change under the transposition σ\sigma — and would thereby cease to be name-invariant, that is, cease to measure the configuration. ◼\blacksquare

5 Failure mode 4 — a scalar that decides is the rule in disguise

The first three results say a measurement-like scalar fails. The fourth closes the other direction: a scalar that does decide placement adds nothing.

Proposition (degeneracy). Any scalar that decides placement is threshold-equivalent to the rule’s own binary verdict.

Proof. Suppose ss decides placement via dd, in either the element-level form s(e,M)s(e,M) or the module-level form s(M)s(M). Let T={x∈ℝ:d(x)=correct}T = \{x \in \mathbb{R} : d(x) = \text{correct}\}, the preimage of the “correct” verdict. Then, using the definition of the verdict, s(e,M)∈T⇔d(s(e,M))=correct⇔VP(e,M)=correct⇔M=[e]P. s(e, M) \in T \iff d(s(e,M)) = \text{correct} \iff V_P(e,M) = \text{correct} \iff M = [e]_P . So the indicator 1[M=[e]P]1[M = [e]_P] is recovered from the scalar by a single threshold test. (For the module-level form, the same unfolding gives s(M)∈T⇔Ms(M) \in T \iff M is a PP-class, since the verdict is uniform across a module.)

The real-valued structure — magnitude, ordering, continuity, distance from the threshold — contributes nothing to the decision. Any two verdict-deciding scalars induce the same partition of element-module pairs, the partition the rule already defines: one scalar might use [0,1][0,1] with threshold 0.50.5, another ℝ\mathbb{R} with threshold 00, but the partition is identical. ◼\blacksquare

6 The four modes cover every scalar

The results assemble into a trichotomy. Every scalar aimed at the placement verdict either lacks the principle, has it but fails to decide, or decides only degenerately.

  1. Principle-blind. No measurement without PP decides placement (failure mode 1).
  2. Non-deciding. With PP, a scalar may fail to decide. For the measurement-like classes the failure is provable: a scalar factoring through the purity/completeness pair cannot determine the failure mode (failure mode 2), and a name-invariant scalar cannot identify the repair target (failure mode 3).
  3. Degenerate. With PP, any scalar that decides placement is threshold-equivalent to the rule’s binary verdict (failure mode 4).

In every case the placement verdict originates in the partitioning rule, not in a number. A number can repeat the rule’s verdict on a module; only the rule can say what is wrong and which element must move.

7 What the scalar is still good for — and what it is not

The result is a limit on deciding. It does not by itself say that a scalar has no practical use — but the usual consolation is weaker than it sounds.

The consolation runs: even if a number cannot decide, it can rank modules for inspection — which to examine first, which grouping looks most suspect. But a ranking asks the scalar to do exactly what the proposition forbids: order modules by comparing an impurity defect with an incompleteness defect on a single line. Any such order presupposes an aggregate g(purity,completeness)g(\text{purity}, \text{completeness}) and, with it, an exchange rate between “an element that does not belong” and “a class member that is missing.” The two axes are independent and incommensurable; nothing in the rule or the domain fixes that rate. Change the aggregate — product, arithmetic mean, weighted sum — and the same modules are ordered differently: a designer ranking by pc\sqrt{pc} and one ranking by 0.7p+0.3c0.7p + 0.3c will name different modules as most suspect, and the rule adjudicates nothing between them.

So even the attention-directing use rests on a convention, not on cohesion. What survives without arbitration is only the degenerate bit: whether a module sits at (1,1)(1,1) or below it — the rule’s own verdict, reproduced by a threshold. Everything finer is a chosen weighting. A scalar score can therefore flag that a module is not a class, and a designer may adopt a heuristic order to decide where to look first — but the order is not grounded in the theory, is not invariant across aggregates, and two defensible scores need not agree.

A separate and weaker point concerns empirical use: structural scores have been reported to correlate with fault-proneness and maintenance effort, so they can serve as screening signals and change predictors. That is a statistical fact about a proxy for change, not a claim that the score measures cohesion — and it does not repair the arbitrariness of ranking by the score.

The impossibility still bites when the score is asked to issue the verdict — to declare an element misplaced from the number alone, without comparing the module against the rule. There, the score is not merely arbitrary; it is the rule in disguise.

8 Where this comes from

The cohesion schema — correctness relative to a partitioning rule, and the (purity, completeness) pair — is defined and developed in On the Nature of Cohesion [1]. The constructive alternative it points to is the per-rule pair for diagnosis, and the rule PP itself for the verdict. The companion page Why two metrics are necessary proves that the pair is the minimal adequate output for a single rule.


The formal development. The definitions, theorems, and proofs behind this page are published in:

All published papers

References

[1]
Y. Loth, “On the nature of cohesion: Cohesion as correctness relative to a partitioning rule.” Zenodo, Jul. 2026. doi: 10.5281/zenodo.21703193.