Visual Studio Code Metrics

2,299 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,299
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
35
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • http://www.amazon.com/Coding-Faster-Getting-Productive-Microsoft/dp/0735649928/
  • CA1502http://msdn.microsoft.com/en-us/library/ms182212.aspx
  • CA1501http://msdn.microsoft.com/en-us/library/ms182213.aspx
  • CA1506http://msdn.microsoft.com/en-us/library/bb397994.aspxhttp://blogs.msdn.com/b/codeanalysis/archive/2007/11/15/code-metrics-as-check-in-policy.aspx
  • CA1506http://msdn.microsoft.com/en-us/library/bb397994.aspxhttp://blogs.msdn.com/b/codeanalysis/archive/2007/11/15/code-metrics-as-check-in-policy.aspx
  • Visual Studio Code Metrics

    1. 1. Code MetricsWhat are they?Why should I care?Lines of Code (LOC)Cyclomatic ComplexityClass Coupling / Coupling Between Objects (CBO)Depth of Inheritance Tree (DIT)Maintainability IndexUsing the Tool Window
    2. 2. What are they?“[…]a measure of some property of a piece of softwareor its specifications […]”http://en.wikipedia.org/wiki/Software_metric“[…] a set of software measures […]”http://msdn.microsoft.com/en-us/library/bb385914.aspx
    3. 3. Why should I care?Find those areas that are (statistically) more likely toproduce problemsDetermine where to focus limited resourcesUnderstand the current state of a solution / projectKeep track of where we have been and where we aregoing
    4. 4. Lines of Code (LOC)Basic Info Raw count of IL lines Not a good measure by itselfStats N/A when used aloneCode Analysis N/A http://academic.research.microsoft.com/Paper/2101790.aspx
    5. 5. Cyclomatic ComplexityBasic Info Count of decisions More decisions means more errors Used often with LOCStats 10 Suggested upper limitCode Analysis CA1502 Avoid excessive complexity 25 http://www.mccabe.com/pdf/mccabe-nist235r.pdf
    6. 6. 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 codeStats Low Less complex Less reuse of code High More complex More reuse of code 5 or 6 for upper limitCode Analysis CA1501 Avoid excessive inheritance http://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricFor 4 OOD_ChidamberKemerer94.pdf
    7. 7. Class Coupling /Coupling Between Objects (CBO)Basic Info Number of classes a single class usesStats 9 Upper limitCode Analysis CA1506 Avoid excessive class coupling 80 for class 30 for method http://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricForOOD_Chidamber Kemerer94.pdf
    8. 8. Maintainability IndexBasic Info Calculates an index value between 0 and 100 that represents the relative ease of maintaining the codeStats High == good Low == bad Ratings Green (20 – 100) Yellow (10 – 19) Red (0 – 9)Code Analysis CA1505 Avoid unmaintainable code 19 or lower
    9. 9. Using the Tool Window

    ×