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 sorts the element set into equivalence classes — the elements that belong together. A module complies when its boundary coincides with its class: for every . Otherwise it deviates in one of two ways:
- Impurity. contains elements from another class. The remedy is to remove them — to split.
- Incompleteness. Some element of the module’s class lies outside . The remedy is to add it — to merge.
Assess a module against a class (the class it should realize). Write
Both values lie in . Purity is exactly when has no foreign element; completeness is exactly when is missing no member of . A module is fully cohesive precisely when both are .
The question of this page: can a single real number 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 that may consult the principle as well as the structure — but whose output is one real number.
Verdict-deciding. decides placement iff there is an interpretation with for every system and every element-module pair. (The module-level form is read the same way; the verdict is uniform across a module, so assigns one verdict to every element of .)
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 , , and the module , with no access to . Then it cannot decide placement, whatever its formula and whatever its precision.
Example. Let and , and let the module under test be .
- Under with a single class , we have , so is incorrectly placed (the module is missing ).
- Under with classes , we have , so is correctly placed.
The two systems present identical structural inputs — same , same , same — 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 underdetermines , so “correct” — which is meaningless without — cannot be read off it. The constructive cell is also visible: give the metric access to and it can compare with . 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 , but let it return one number per module, built from the two-axis pair: for some .
Proposition (aggregation ambiguity). (a) If is symmetric — — there are two modules with opposite defects and opposite remedies whose scores are exactly equal. (b) If 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 with a class of size , and four foreign elements all belonging to another class.
- Let , so . Then and : impure but complete — the remedy is to remove the four foreign elements.
- Let for two elements . Then and : pure but incomplete — the remedy is to add the two missing members.
Both modules can be realized in one system .
(a) By symmetry, : the scores coincide exactly, while the defects and the required repairs are opposite. The geometric mean scores both modules at .
(b) Consider the two boundary curves (impure-but-complete) and (pure-but-incomplete). Because is strictly increasing, is the supremum of on both curves; because is continuous, each image , is an interval with that same supremum. Two intervals with a common supremum overlap: there exist and with . 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.”
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 is name-invariant: renaming the elements — carrying one system to another by a bijection with , , — leaves the score unchanged, . 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 , and the same score, whose minimal repairs move different elements.
Proof. Let , let , and let .
- System 1. induces classes and . Then is not a -class, and the unique one-move repair is to remove : is a -class, while no other single move produces one.
- System 2. induces classes and . Again is not a class, and the unique one-move repair is to remove : .
Now take the transposition , which exchanges and and fixes and . It carries system 1 to system 2: , , , and (the set is fixed as a set).
By name-invariance, : the score is the same in both systems. But the repair targets differ — in system 1, 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 rather than would have to change under the transposition — and would thereby cease to be name-invariant, that is, cease to measure the configuration.
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 decides placement via , in either the element-level form or the module-level form . Let , the preimage of the “correct” verdict. Then, using the definition of the verdict, So the indicator is recovered from the scalar by a single threshold test. (For the module-level form, the same unfolding gives is a -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 with threshold , another with threshold , but the partition is identical.
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.
- Principle-blind. No measurement without decides placement (failure mode 1).
- Non-deciding. With , 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).
- Degenerate. With , 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 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 and one ranking by 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 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 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:
- On the Nature of Cohesion: Cohesion as Correctness Relative to a Partitioning Rule — Zenodo, 2026 — doi:10.5281/zenodo.21703193