Skip to content
Jan Arends edited this page Mar 11, 2025 · 6 revisions

The cargo-workspace-analyzer inspects the coupling of dependancies within a Cargo workspace. Packages should be loosly coupled and should have a high cohesion.
This tool identifies the coupling and hence architectural depts with the package organization.

Metrics

Definitions (from Robert C. Martin’s Stability Metrics)

Fan In:

  • The number of other packages that depend on a given package, so the number of incoming dependencies.
  • A package with high value is likely critical for the system, and changes to it will have a wide impact.
  • In the future I may enhance this to support actual Afferent Coupling defined by Robert C. Martin.

Fan Out:

  • The number of packages that a given package depends on, so the number of outgoing dependencies.
  • A package with high value may be fragile because changes in its dependencies can affect it.
  • In the future I may enhance this to support actual Efferent Coupling defined by Robert C. Martin.

Instability Metric

  • A ratio that helps understand how “volatile” a package is
    • I = 0 means the package is very stable (many depend on it but it doesn’t depend on others).
    • I = 1 means the package is volatile (depends on others but isn’t depended upon much).
  • Introduced in “Design Principles and Design Patterns” by Robert C. Martin (2000).
  • This metric by definition is calculated on Efferent and Afferent Coupling and not Fan In/Out. But here I used the simpler metrics.

Clone this wiki locally