Core Idea

Abstractness is a software package metric measuring the ratio of abstract elements (interfaces and abstract classes) to total classes within a component.

Definition

Abstractness is a software package metric measuring the ratio of abstract elements (interfaces and abstract classes) to total classes within a component. Formally: A = Na / Nc, where Na is the count of abstract types and Nc is total classes. Values range from 0 (completely concrete) to 1 (completely abstract). Abstractness quantifies a component’s design philosophy and is evaluated alongside Instability to assess architectural health.

Key Characteristics

  • Normalized ratio: Values between 0 and 1, enabling comparison across different-sized packages
  • Language-dependent: In Java/C#, counts interfaces and abstract classes; adapts to language constructs
  • Component-level metric: Applied to packages or modules, not individual classes or entire systems
  • Pairs with stability: High abstractness typically pairs with high stability (Stable Abstractions Principle)
  • Main sequence relationship: Combined with Instability to calculate Distance-from-Main-Sequence
  • Context-dependent targets: Domain cores often have higher abstractness than infrastructure layers

Examples

  • Pure interface package (A=1.0): Package with only interfaces like UserRepository, PaymentGateway—completely abstract
  • Implementation package (A=0.0): Concrete classes like PostgresUserRepository, StripePaymentGateway—completely concrete
  • Domain model layer (A=0.7-0.9): Core business logic with interface-defined contracts and minimal concrete classes
  • Infrastructure layer (A=0.1-0.3): Database adapters and API clients with mostly concrete implementations

Why It Matters

Abstractness provides quantitative assessment of component design quality and dependency principle adherence. Highly stable components with low abstractness violate the Stable Abstractions Principle, becoming rigid and difficult to change. Highly abstract components with no implementations become useless abstractions.

Combined with Afferent-Coupling, Efferent-Coupling, and Instability metrics, abstractness identifies architectural violations through Distance-from-Main-Sequence analysis. Components far from the ideal balance require redesign. This enables data-driven Component-Based-Decomposition when breaking apart monoliths or refactoring service boundaries, and supports architectural fitness functions that monitor structural properties over time.

  • Instability - The companion metric measuring coupling ratios, combined with abstractness to assess component position
  • Distance-from-Main-Sequence - Calculated using abstractness and instability to identify architectural violations
  • Afferent-Coupling - Incoming dependencies that contribute to stability calculations
  • Efferent-Coupling - Outgoing dependencies that contribute to instability calculations
  • Component - The architectural unit to which abstractness measurements apply
  • Modularity - The broader design principle that abstractness helps quantify
  • Component-Based-Decomposition - Decomposition strategy that uses abstractness metrics to identify service boundaries

Sources

  • Martin, Robert C. (2002). Agile Software Development: Principles, Patterns, and Practices. Pearson Education. ISBN: 0-13-597444-5.

    • Pages 262-264: Abstractness metric definition and package design principles
  • Ford, Neal; Richards, Mark; Sadalage, Pramod; Dehghani, Zhamak (2022). Software Architecture: The Hard Parts. O’Reilly Media. ISBN: 978-1-492-08689-5.

    • Chapter 4: Component-based decomposition using abstractness metrics
  • Wikipedia contributors (2024). “Software package metrics.” Wikipedia.

  • Martin, Robert C. (2012). “The Clean Architecture.” Clean Coder Blog.

Note

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.