Cheat sheetCD-05

Architecture Metrics

Core Design / Architecture Metrics

Metrics turn structural opinions into numbers: afferent/efferent coupling, cohesion, connascence (type + strength + locality), and cyclomatic complexity — feedstock for fitness-function governance.

01
Coupling (Ca/Ce)Afferent = incoming (who depends on me); efferent = outgoing (who I depend on). Both raise cost of change.
02
CohesionHow well a component's elements belong together; high is good, low signals split-worthy responsibilities.
03
ConnascenceChange-in-one-needs-change-in-other coupling; has type, strength, locality. Prefer weaker, weaker at distance.
04
Cyclomatic complexityIndependent paths through code (~decisions + 1); higher means more tests and lower maintainability.

Measure before asserting: compute Ca/Ce to find load-bearing and fragile components, check cohesion to spot mixed responsibilities, and reduce strong or distant connascence (e.g. positional to named arguments). Set thresholds on coupling and cyclomatic complexity and wire them into fitness functions so structural health is enforced continuously.

Load-bearing componentNotifications with Ca = 10, Ce = 3: high afferent coupling means it needs a stable contract and careful evolution.
Weakening connascenceA distant caller passing positional args is connascence of position; named parameters weaken it to connascence of name.
Ca = afferent (incoming) ; Ce = efferent (outgoing)
cohesion high = one job; low = split candidate
connascence = type + strength + locality
rule: weaker connascence, weaker still at distance
cyclomatic complexity ~ decision points + 1
metricscouplingcohesionconnascencecyclomatic-complexityfitness-functions
review in 6d