Please see my other Miscellaneous articles.
Using Visual Studio to guide refactoring
Visual Studio provides the following powerful metrics to help guide developers as they seek opportunities for refactoring.
To begin the code metrics analyzer, r-click the project -> Analyze and Code Cleanup -> Calculate Code Metrics.
You will then be presented with a code hierarchy and scores for each level as follows.
Metric | Goal | Notes |
Class Coupling | Low | The greater amount of coupling or dependencies to other classes, the more difficult to test. |
Cyclomatic complexity | Low | A high value denotes an excessive amount of return paths. |
Lines of Source Code vs. Lines of Executable Code | Narrow Margin | The greater the margin between source code and executable code, the less the Single Responsibility Principle (SRP) is being followed. |
Maintainability | High | A low index represents a higher difficulty in maintaining the level (function) during future changes – seek to decrease numerous if…else blocks, return paths, etc. Follow the Single Responsibility Principle (SRP). |