Skip to content

ALL-ARCH0003 · dependency_on_a_less_stable_module

Count package dependencies that point toward something less stable.

This is a deterministic rule for all languages. Read its implementation.

Stability here is not a guess about how often a file changes, it is counted. A package that five others import and that imports one itself is hard to change, because five callers feel it, and Martin writes that as instability I = Ce / (Ca + Ce), which is zero when nothing can push a change into the module and one when everything can. The Stable Dependencies Principle says an arrow must point toward stability, so an import from a package with a low I to a package with a higher one is reported, and tolerance is the slack a project allows before a difference counts.

This is a layering violation found without anybody naming a layer. A written contract in a configuration file states which package may import which, and it rots the first time somebody adds a legitimate edge and widens the rule to keep the build green, until the file describes the code instead of constraining it. The dependency graph already says which modules the repository leans on, so the constraint can be derived every run and cannot drift away from what the code does.

Continue with evidence and references, or open the examples.