You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ArchUnit supports checking for dependencies between classes using com.tngtech.archunit.lang.conditions.AnyDependencyCondition via com.tngtech.archunit.lang.conditions.ArchConditions.dependOnClassesThat(DescribedPredicate<? super JavaClass>).
However, this Condition does not cover indirect dependencies.
Checking for immediate dependencies ist sufficient in projects where there exists a consistent architectural guideline that specifies for every package / class the allowed dependencies.
When refactoring a large legacy project without such detailed guidelines, one might still pose independence constraints on two (groups of) classes, but defining guidelines for all indirectly referenced classes would be too expensive. In this case, one has to check for the absence of transitive dependencies.
As a Proof of Concept, I have implemented a subclass TransitiveDependenceCondition of ArchCondition. It checks for transitive dependencies from the current class to some target class satisfying a target-condition, without passing through other classes matching some ignore-condition.
When used on about 20.000 classes, a check for transitive independence takes much less than the import of all classes. Hence the transitive dependency check itself is not really expensive.
Although this POC is working in our project, it is still preliminary and not as general as it could be.
The text was updated successfully, but these errors were encountered:
ArchUnit supports checking for dependencies between classes using com.tngtech.archunit.lang.conditions.AnyDependencyCondition via com.tngtech.archunit.lang.conditions.ArchConditions.dependOnClassesThat(DescribedPredicate<? super JavaClass>).
However, this Condition does not cover indirect dependencies.
Checking for immediate dependencies ist sufficient in projects where there exists a consistent architectural guideline that specifies for every package / class the allowed dependencies.
When refactoring a large legacy project without such detailed guidelines, one might still pose independence constraints on two (groups of) classes, but defining guidelines for all indirectly referenced classes would be too expensive. In this case, one has to check for the absence of transitive dependencies.
As a Proof of Concept, I have implemented a subclass TransitiveDependenceCondition of ArchCondition. It checks for transitive dependencies from the current class to some target class satisfying a target-condition, without passing through other classes matching some ignore-condition.
When used on about 20.000 classes, a check for transitive independence takes much less than the import of all classes. Hence the transitive dependency check itself is not really expensive.
Although this POC is working in our project, it is still preliminary and not as general as it could be.
The text was updated successfully, but these errors were encountered: