October 6, 2007 1:47 AM
by Ed Kisinger
VS 2008 has added a new feature called Code Metrics (CM). Code Metrics is a way to produce actionable information on a project or solution. When you generate CM on your code it produces such things as Maintainability Index, Cyclomatic Complexity, Class Coupling, Inheritance depth and lines of code.
Here is a brief description of each:Cyclomatic Complexity: How many paths of execution are in your code. i.e. Enter a Method, That's 1, Hit an If, That's 2, Hit an Else, That's 3. This has a Cyclomatic complexity of 3. Here is more robust definition.Class Coupling: Indicates how many other classes relate to this classInheritance depth: The level of inheritanceLines of code: Self explanatory, everyone's favoriteMaintainability Index: An aggregate of the above metrics.
Each of these are shown at the assembly level then it allows you to drill down to the namespace, class and method level.
Why is this so cool? Being able to produce and show these metrics allows you to better manage existing code and produce more manageable new code, which in turn pushes you and your team to code to better standards. These metrics are actionable, meaning they enable you to do something with your code by visually displaying the information and giving you the ability to actually assign a work item right from the Code Metrics result window and attach the information to it as well.
This is only one tool in the suite of tools within VS 2008 that will enable and guide you to produce better, more secure and performant code. Harness the power of them all!
The Code Metrics result window; user adding a work item based off metrics:
Work item created from Metrics. Notice the how the work item has all the information attached via the "History" tab.
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u
Ed Blankenship is a Product Manager at Microsoft for Visual Studio Online. I am an author of a few books, former Microsoft MVP of the Year, and former ALM consultant. I hold Office Hours each week if you are interested in chatting.
Managed Windows Shared Hosting by OrcsWeb
Site design by Jeremy Kratz