How well your code doing? - Visual Studio Code Metrics
Today when I completed my work, I just curious how many lines of code that I have wrote so far. So I search how to calculate the lines of code and I found Visual Studio Code Metrics: A very valuable information source about your code and your solution. So I went little more deeper to understand what all these counts mean.
And I was so interested with my findings and I thought I have to share these with you.
I think this is a very cool and important feature of Visual Studio.
So how to view these numbers? Simple, just navigate to Analyze → Calculate Code Metrics
And it will give you some numbers according the number of project that you have in your solution.
In my case there are 8 project and here are my results:
Ok, let's see what are these calculations and what are these numbers are and most importantly what are those mean to you.
Maintainability Index
This index shows how easy or hard to maintain or modify your code. This will give a number between 0-100 and color coded ratings can be used to quickly identify trouble spots in your code.
0-9 = Hard to maintain
10-19 = Need to put some affect to modify
20-100 = Well structured and easy to do modifications
Cyclomatic Complexity
Measures the structural complexity of the code. A program that has complex control flow requires more tests to achieve good code coverage and is less maintainable.
Which means higher the number higher the complexity.
Depth of Inheritance
Indicates the number of different classes that inherit from one another, all the way back to the base class. The higher this number, the deeper the inheritance and the higher the potential for base class modifications to result in a breaking change.
For Depth of Inheritance, a low value is good and a high value is bad.
Class Coupling
Measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration. Good software design dictates that types and methods should have high cohesion and low coupling. So, this is where your OOP practices comes to play so keep on applying those down the road.
Which means higher the number, higher the coupling is.
Lines of Code
This is simply how many lines that you have wrote in your solution.
I think this is really important to check on these numbers after implementing new features of introducing new library, framework or a software development pattern. So then, if the numbers are looks bad you can consider refactoring code to maintain the quality and future modifications.
Reference
https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-values?view=vs-2019
Hope your code is feeling good and keeping it's good health :)
And I was so interested with my findings and I thought I have to share these with you.
I think this is a very cool and important feature of Visual Studio.
So how to view these numbers? Simple, just navigate to Analyze → Calculate Code Metrics
And it will give you some numbers according the number of project that you have in your solution.
In my case there are 8 project and here are my results:
Maintainability Index
This index shows how easy or hard to maintain or modify your code. This will give a number between 0-100 and color coded ratings can be used to quickly identify trouble spots in your code.
0-9 = Hard to maintain
10-19 = Need to put some affect to modify
20-100 = Well structured and easy to do modifications
Cyclomatic Complexity
Measures the structural complexity of the code. A program that has complex control flow requires more tests to achieve good code coverage and is less maintainable.
Which means higher the number higher the complexity.
Depth of Inheritance
Indicates the number of different classes that inherit from one another, all the way back to the base class. The higher this number, the deeper the inheritance and the higher the potential for base class modifications to result in a breaking change.
For Depth of Inheritance, a low value is good and a high value is bad.
Class Coupling
Measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration. Good software design dictates that types and methods should have high cohesion and low coupling. So, this is where your OOP practices comes to play so keep on applying those down the road.
Which means higher the number, higher the coupling is.
Lines of Code
This is simply how many lines that you have wrote in your solution.
I think this is really important to check on these numbers after implementing new features of introducing new library, framework or a software development pattern. So then, if the numbers are looks bad you can consider refactoring code to maintain the quality and future modifications.
Reference
https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-values?view=vs-2019
Hope your code is feeling good and keeping it's good health :)
Comments
Post a Comment