代码度量计算在Visual Studio [英] Code Metrics Calculation in Visual Studio
问题描述
什么是代码度量计算以下
What is the prefered score range for the code metrics calculation for the following
- 维修性指标
- 圈复杂度
- 继承深度
- 类耦合
的首选分数范围
- Maintainability Index
- Cyclomatic Complexity
- Depth of Inheritance
- class Coupling
推荐答案
理论上的最优值是:
- 可维护性指数:100值越高表示。更好的可维护性
- 圈复杂度:1。该代码可以采取不同的路径数
- 继承深度:1.类的数上述定义这一个在继承树,不包括接口
- 类耦合:0.其他实体的数目这个实体是依赖于
- Maintainability index: 100. Higher values indicate better maintainability.
- Cyclomatic complexity: 1. The number of different paths that code can take.
- Depth of inheritance: 1. The number of class definitions above this one in the inheritance tree, not including interfaces.
- Class coupling: 0. Number of other entities this entity is dependent on.
有没有一成不变的好的范围,尽管它可能作出一些一般性发言。
There are no hard and fast "good" ranges, though it's possible to make some general statements.
- 具有高每方法圈复杂度提出的方法变得过于复杂。
- 有一个继承深度大于约3或4个以上(你自己的类,而不是框架的)是,你可能会不必要地代表抽象的关系,这是不是真的在你的软件的域的风吹草动。
- 低耦合类是一般的好,但有时是不可避免的。在可能的情况,你一定要尽量减少命名空间之间的依赖关系,因为这里有一个为依赖性理由要少得多。
一个项目只能通过实质上什么都不做,并成为无用同时到达的所有四个值:软件,什么都不做,取决于什么肯定是维护,但不是一个很好用的客户端美元
A project could only reach all four values simultaneously by essentially doing nothing and being useless: software that does nothing and depends on nothing is certainly maintainable, but not a very good use of client dollars.
因此,所有的复杂性是一个折衷:附加所谓的固有的复杂编码更复杂到程序,允许它扩大功能集。你想避免是的偶然的复杂度由一个贫穷或缺乏实施出台。
Therefore, all complexity is a tradeoff: additional so-called inherent complexity encodes more sophistication into the program, allowing it to expand the feature set. What you would like to avoid is accidental complexity introduced by a poor or deficient implementation.
这篇关于代码度量计算在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!