Yesky首页| 产品报价| 行情| 手机 | 数码 | 笔记本 | 台式机 | DIY硬件 | 外设 | 网络 | 数字家庭 | 评测 | 软件 | e时代 | 游戏 | 图片 | 壁纸 | 群乐 | 社区 | 博客 | 下载
软件频道>程序开发>JavaVBVCDelphiC/C++Web开发微软专栏移动数据库程序人生软件工程|Comet程序开发
您现在的位置: 天极网 > 开发频道 > Visual Studio2008的新功能:代码度量
全文
群乐:VC

Visual Studio2008的新功能:代码度量

2008-04-09 15:56 作者: 风海迷沙 出处: 天极网 责任编辑:>孙蓬阳

    原文发表地址:Visual Studio 2008 Code Metrics Saves you Money

     原文发表时间:Wednesday, October 03, 2007 7:00 AM

     原作者:David M. Kean

  While we've already briefly spoken about Code Metrics when we announced it, I thought I would discuss it in a little more depth, in particular the metrics it provides.

  As mentioned previously, Code Metrics is a new tool window that helps users find and act upon complex and un maintainable areas within an application.

  我们已经在这篇文章简要的介绍了关于代码度量功能的信息,我认为应该在这里更深入的讨论一下,特别是它提供的度量标准。

  就像之前提到的一样,代码度量功能是一个新的工具窗口,它帮助用户在里面查找到复杂和不可维护的区域。

  The following shows the results of running Code Metrics over a fictional business application:

  

  下面这张图片显示一个虚构的商业项目应用执行了代码度量的结果(译注:我拿自己的一个项目抓个图,方便使用简体中文版的朋友进行对比):

  

  As you can see from above, for Visual Studio 2008, we're providing five metrics. These are detailed below.

  就像你在上面看到的,我们为Visual Studio 2008 提供了5个度量值,以下是它们的详细信息及计算方法:Class Coupling

  At each level, this indicates the total number of dependencies that the item has on other types. This number excludes primitive and built-in types such as Int32, String and Object. The higher this number, the more likely changes in other types will ripple though this item. A lower value at the type level can indicate candidates for possible reuse. The following shows how coupling is calculated:

  类耦合

  在每个级别上,它表明了类对其它类型的依赖总数。这个数字不包括基类(原始类型)比如Int32,String和Object,这个数字越大,表明改动它时对其它类型的影响就越大。如果这个值比较低则表明它的代码重用的可能性越高。

  下面这张图耦合值是如何被计算出来的:(译注:说白了就是没有这个类,会有几个类会挂掉。)

  

  For example, as you can see above, Account is coupled to two other types, Addressand Order, whereas Countryis not dependent on any other type.

  以上面的图为例Account 和两个其它类型耦合,Address和Order,然而Country没有依赖于任何类型。Depth of Inheritance

  At the type level, depth of inheritance indicates the number of types that are above the type in the inheritance tree. For example, a type that derives directly from Object would have a depth of inheritance of 1. At the namespace and project level, this indicates the highest depth of inheritance of all the types contained within it. This number does not take into consideration the depth of any implemented interfaces. Deep inheritance trees can indicate an over-engineering of a problem and can increase the complexity of testing and maintaining an application.

  继承深度

  在这个度量值级别上,继承深度指这个类型在继承树上的有多少类型。例如,一个类型直接从Object上继承的话,它的深度就是1。在命名空间和项目中,它表明所有类型(包括自身)的最大的深度值。这个数字不考虑任何应用接口。深度继承树可以在维护一个应用程序表现出过度设计和增加测试复杂度的问题。The following shows how depth is calculated:

  下面展示了深度是如何被计算的:

  

  For example, in the above inheritance hierarchy, ListControland Label have a depth of inheritance of 3, whereas Componenthas a depth of inheritance of 1.

  以上图的继承层次为例,ListControl和Label位于继承的第3层,然而Component的深度为1.Cyclomatic Complexity

  At each level, this measures the total number of individual paths through the code. This is basically calculated by counting the number of decision points (such as ifblocks, switchcases, and do, while,foreachand forloops) and adding 1. This number is also a good indication on the number of unit tests it will take to achieve full line coverage. Lower is typically better.

共2页。 1 2 :
网友关注
最新上市
编辑推荐
欢迎订阅天极网RSS聚合资讯:http://www.yesky.com/index.xml