Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Studio Tips and Tricks Code Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft Blog: blogs.msdn.com/

Similar presentations


Presentation on theme: "Visual Studio Tips and Tricks Code Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft Blog: blogs.msdn.com/"— Presentation transcript:

1 Visual Studio Tips and Tricks Code Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft Email: zainnab@microsoft.com Twitter: @zainnab Blog: blogs.msdn.com/ zainnab

2

3 Code Metrics What are they? Why should I care? Lines of Code (LOC) Cyclomatic Complexity Class Coupling / Coupling Between Objects (CBO) Depth of Inheritance Tree (DIT) Maintainability Index Using the Tool Window

4 What are they? “[…]a measure of some property of a piece of software or its specifications […]” http://en.wikipedia.org/wiki/Software_metric “[…] a set of software measures […]” http://msdn.microsoft.com/en-us/library/bb385914.aspx

5 Why should I care? Find those areas that are (statistically) more likely to produce problems Determine where to focus limited resources Understand the current state of a solution / project Keep track of where we have been and where we are going

6 Lines of Code (LOC) Basic Info Raw count of IL lines Not a good measure by itself Stats N/A when used alone Code Analysis N/A http://academic.research.microsoft.com/Paper/2101790.aspx

7 Cyclomatic Complexity Basic Info Count of decisions More decisions means more errors Used often with LOC Stats 10 Suggested upper limit Code Analysis CA1502 25 Upper limit http://www.mccabe.com/pdf/mccabe-nist235r.pdf

8 Depth of Inheritance (DIT) Basic Info The maximum length from the node to the root of the inheritance tree Three assumptions Deeper == harder to predict behavior Deeper == greater design complexity Deeper == more reuse of code Stats Low Less complex Less reuse of code High More complex More reuse of code 5 or 6 for upper limit Code Analysis CA1501 http://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricFor OOD_ChidamberKemerer94.pdf

9 Class Coupling / Coupling Between Objects (CBO) Basic Info Number of classes a single class uses Stats 9 Upper limit Code Analysis CA1506 80 for class 30 for method http://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricForOOD_Chidamber Kemerer94.pdf

10 Maintainability Index Basic Info Calculates an index value between 0 and 100 that represents the relative ease of maintaining the code Stats High == good Low == bad Ratings Green (20 – 100) Yellow (10 – 19) Red (0 – 9) Code Analysis CA1505 19 or lower threshold

11 Using the Tool Window

12


Download ppt "Visual Studio Tips and Tricks Code Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft Blog: blogs.msdn.com/"

Similar presentations


Ads by Google