Class VisibilityMetrics

java.lang.Object
com.tngtech.archunit.library.metrics.VisibilityMetrics

@PublicAPI(usage=ACCESS) public final class VisibilityMetrics extends Object
Calculates visibility metrics as defined by Herbert Dowalil in his book "Modulare Softwarearchitektur: Nachhaltiger Entwurf durch Microservices, Modulithen und SOA 2.0".
Visibility refers to the property, if an element of a component is accessible from outside of the component. An example would be a package, where public classes are visible from outside of the package, while package-private, protected and private classes are not. The metrics are calculated by introducing the following definitions:
  • Relative Visibility (RV): num(visible_elements) / num(all_elements) for each component
  • Average Relative Visibility (ARV): The average of all RV values
  • Global Relative Visibility (GRV): num(visible_elements) / num(all_elements) over all components

Consider the following example:

 Component1 (Visible: 2 / Invisible: 4)
 Component2 (Visible: 3 / Invisible: 3)
 Component3 (Visible 1 / Invisible: 9)
 
Then
RV(Component1) = 2 / 6 = 0.33
RV(Component2) = 3 / 6 = 0.5
RV(Component3) = 1 / 10 = 0.1
ARV = (0.33 + 0.5 + 0.1) / 3 = 0.31
GRV = 6 / 22 = 0.27.