Architecture Anti-Patterns: Automatically Detectable Violations of Design Principles

Reviewed by Greg Wilson / 2022-03-14
Keywords: Anti-patterns, Software Architecture

The introduction to this paper lays out an ambitious agenda:

After examining the source code and revision histories of over 100 open-source and industrial software projects, we have observed that there are just a few distinct types of architecture anti-patterns that occur in all the projects we have studied. We will show that files involved in these anti-patterns tend to have more bugs, more changes, and consume more effort, and thus they should be identified. To improve the quality and productivity of a project, the architectural problems behind these file groups should be fixed first.

The six anti-patterns the authors focus on are:

  1. Unstable interfaces (i.e., a widely-used interface that changes frequently).
  2. Modularity violation groups, which are groups of modules that change in tandem even though they have no apparent structural dependencies.
  3. An unhealthy inheritance hierarchy that violates the Liskov Substitution Principle or Dependency Inversion Principle.
  4. A crossing, which they define as a file with both high fan-in and high fan-out.
  5. Cliques of files with cyclic dependencies.
  6. Package cycles that violate strictly hierarchical structure.

The paper describes algorithmic rules that operationalize these concepts and presents an example of each kind of issue. It then goes on to show that the frequency and churn of both bugs and changes is measurably higher for files with these anti-patterns than for files without them.

While I am generally skeptical of software metrics (see this post for discussion), this work shows that it is possible to measure things in a project's source code and history that can help teams focus their effort where it will have the most impact.

Mo2021 Ran Mo, Yuanfang Cai, Rick Kazman, Lu Xiao, and Qiong Feng: Architecture anti-patterns: automatically detectable violations of design principles. IEEE Trans. Software Engineering, 47(5), 2021, doi:10.1109/tse.2019.2910856.

In large-scale software systems, error-prone or change-prone files rarely stand alone. They are typically architecturally connected and their connections usually exhibit architecture problems causing the propagation of error-proneness or change-proneness. In this paper, we propose and empirically validate a suite of architecture anti-patterns that occur in all large-scale software systems and are involved in high maintenance costs. We define these architecture anti-patterns based on fundamental design principles and Baldwin and Clark's design rule theory. We can automatically detect these anti-patterns by analyzing a project's structural relationships and revision history. Through our analyses of 19 large-scale software projects, we demonstrate that these architecture anti-patterns have significant impact on files' bug-proneness and change-proneness. In particular, we show that 1) files involved in these architecture anti-patterns are more error-prone and change-prone; 2) the more anti-patterns a file is involved in, the more error-prone and change-prone it is; and 3) while all of our defined architecture anti-patterns contribute to file's error-proneness and change-proneness, Unstable Interface and Crossing contribute the most by far.