1 / 12

Visual Studio Tips and Tricks Code Metrics

Email: zainnab@microsoft.com Twitter: @zainnab Blog: blogs.msdn.com/ zainna b. Visual Studio Tips and Tricks Code Metrics. Zain Naboulsi Sr. Developer Evangelist Microsoft. Code Metrics. What are they? Why should I care? Lines of Code (LOC) Cyclomatic Complexity

gareth
Download Presentation

Visual Studio Tips and Tricks Code Metrics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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

More Related