28.8. Dependency

28.8.1. Description

The Dependency reduction function computes a single telemetry stream representing dependency information.

28.8.2. Parameter

Table 28.7. 

ParameterDescriptionDefault
metricNameOne of 'InboundInternal', 'OutboundInternal', 'InboundExternal', 'OutboundExternal', 'Cycles', 'EfferentCouplings' or 'AfferentCouplings'.OutboundInternal
filePatternAnt-like file pattern specifying the files to be included in computation.**

28.8.3. Example

Example 28.9. Java Class Dependency using DependencyFinder

streams DependencyStream(metricName, filePattern) = {
   "Dependency", JavaDependency(metricName, filePattern)
};

y-axis yAxis(label) = {label};

chart DependencyChart() = {
  "Extenal Inbound Dependency", 
  (DependencyStream("InboundExternal", "**/hackyCore_Kernel/**"), yAxis("External Inbound Dependency"))
};

draw DependencyChart();

This chart shows the number of external inbound dependencies on the hackyCore_Kernel module. The number increased from 2922 to 2966 during the eight weeks covered by this chart, which indicated that more and more Java code in other modules were dependent on the hackyCore_Kernel module.

28.8.4. Example

Example 28.10. Java Class Dependency using JDepend

y-axis yAxis(label) = {label, "integer"};

streams DependencyStream(metricName, filePattern) = {
   "Dependency", JavaDependency(metricName, filePattern)
};

chart DependencyWithCycles(filePattern) = {
  "Dependency with Cycles", 
  (DependencyStream("Cycles", filePattern), yAxis("Dependency")),
  (DependencyStream("AfferentCouplings", filePattern), yAxis("Dependency")),
  (DependencyStream("EfferentCouplings", filePattern), yAxis("Dependency"))
};

draw DependencyChart();

This chart shows the evolution of three dependency measures in a sample project. The data collection was done using JDepend. During the time period from Feb 21 to Feb 27, some refactoring work was done which reduced the cyclic dependencies within the project.