JDepend使用手册
介绍
JDepend traverses Java class file directories and generates design quality metrics for each Java package. JDepend allows you to automatically measure the quality of a design in terms of its extensibility, reusability, and maintainability to manage package dependencies effectively.
JDependy 对于每一个java package 生成一个quality metrics, JDepend 用来考察软件设计 的可扩展性,重用性,可维护性。
Term
- Number of Classes and Interfaces (类和接口数)
The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.
- Afferent Couplings (Ca) (其他包的类对该包的依赖,表明了该包职责)
The number of other packages that depend upon classes within the package is an indicator of the package's responsibility.
- Efferent Couplings (Ce) (该包所依赖的其他包的类数,表明其独立性)
The number of other packages that the classes in the package depend upon is an indicator of the package's independence.
- Abstractness (A) (该包的抽象程度)
The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package.
- Instability (I) (包稳定性)
The ratio of efferent coupling (Ce) to total coupling (Ce + Ca) such that I = Ce / (Ce + Ca). This metric is an indicator of the package's resilience to change. The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package.
- Distance from the Main Sequence (D) (偏离主序列的距离)
The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and instable (x=1, y=0). 主序列是笛卡儿坐标上从 X=0 和 Y=1 到 X=1 和Y=0 的一条直线,如图1所示:
图1. 主序列
通过沿着这条直线绘制包并测量它们到主序列的距离,可以推断包的平衡。如果包对于抽象性和不稳定性是平衡的,它的距离就接近于0,如果包不平衡,那么它距离主序列的距离就接近于1,如图2所示:
图2. 到主序列的距离
检查到主序列的距离 度量会产生有趣的结果。例如,上面的user包生成的值为0。就一个实现包来说,这个包是平衡的,即高度不稳定。总体来说,“到主序列的距离”度量尝试补偿实际实现。没有代码基包含所有抽象性和不稳定性值为 1 或 0 的包 —— 多数包的值位于这两个数字之间。通过监视“到主序列的距离” 度量,可以衡量包是否正在变得不平衡。寻找偏远的值,如值接近于 1 的包(这表示它们距离主序列尽可能地远),有助于了解特定的不平衡如何影响架构的可维护性(例如,通过脆弱性)。
The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible.
- Package Dependency Cycles (循环依赖)
Package dependency cycles are reported along with the hierarchical paths of packages participating in package dependency cycles.