Core Idea

Afferent coupling (Ca) measures the number of external components that depend on a given component, quantifying incoming dependencies and serving as an indicator of the component’s responsibility and stability.

Definition

Afferent Coupling (Ca) measures the number of external components that depend on a given component. First proposed by Robert C. Martin (1994), it quantifies incoming dependencies—the classes, modules, or packages that rely on the inspected component. High Ca values indicate that many system parts depend on this component, making it central to the architecture.

Key Characteristics

  • Inward dependency metric: Counts how many external components depend on the inspected component—not what the component itself depends on
  • Stability indicator: High afferent coupling typically signals high stability; changes to widely-depended-upon components risk cascading failures
  • Responsibility signal: High-Ca components often fulfill core responsibilities—error handling frameworks, logging utilities, domain model entities
  • Not inherently bad: High Ca is expected for foundational components such as core frameworks, utility libraries, and infrastructure code
  • Instability calculation: Ca combines with Efferent-Coupling (Ce) to calculate Instability: I = Ce / (Ce + Ca)
  • Change amplification: Modifications to high-Ca components require extensive testing and careful versioning

Why It Matters

  • Architectural anchors: High-Ca components become de facto anchors—they must remain stable because many parts depend on them, requiring comprehensive test coverage and rigorous change control
  • Reveals actual architecture: Ca exposes where responsibility concentrates and where refactoring might reduce unwanted centralization, showing the actual (not intended) architecture
  • Stable Dependencies Principle: Combined with Efferent-Coupling, afferent coupling enables calculating component instability and assessing alignment with SDP

Sources

AI Assistance

This content was drafted with assistance from AI tools for research, organization, and initial content generation. All final content has been reviewed, fact-checked, and edited by the author to ensure accuracy and alignment with the author’s intentions and perspective.