Download
visual studio tips and tricks code metrics n.
Skip this Video
Loading SlideShow in 5 Seconds..
Visual Studio Tips and Tricks Code Metrics PowerPoint Presentation
Download Presentation
Visual Studio Tips and Tricks Code Metrics

Visual Studio Tips and Tricks Code Metrics

165 Vues Download Presentation
Télécharger la présentation

Visual Studio Tips and Tricks Code Metrics

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Email:zainnab@microsoft.com Twitter: @zainnab Blog:blogs.msdn.com/zainnab Visual StudioTips and TricksCode Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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/MetricForOOD_ChidamberKemerer94.pdf

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

  9. 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

  10. Using the Tool Window