PMD rule God Class - understanding the metrics

孤者浪人 提交于 2019-12-05 07:23:47
  • WMC = Weighted Methods Count
  • ATFD = Access To Foreign Data
  • TCC = Tight Class Cohesion

Baselines seems to be defined as constant values. If you would like to know more, you can find the implementation here.

WMC stands for Weighted Methods Count or Weighted Method per Class. The WMC metric is defined as the sum of complexities of all methods declared in a class. This metric is a good indicator how much effort will be necessary to maintain and develop a particular class.

ATFD stands for Access to Foreign Data. This metric represents the number of external classes from which a given class accesses attributes, directly or via accessor-methods.

TCC stands for Tight Class Cohesion. TCC is the relative number of methods directly connected via accesses of attributes.

The code triggers a violation if WMC >= 47 and ATFD > 5 and TCC < 1/3.

You can read about the God class on page 55 in Object-Oriented Metrics in Practice (and you do not have to buy the book to just read 1 page). You can also read the PMD documentation.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!