sniff solid violation using code metric visual studio
TRANSCRIPT
Sniff S.O.L.I.D violation using Code Metrics Visual Studio
By Freddy MunandarHomework of Agile Principles, Patterns and Practices (by Uncle Bob)
Code Metrics Essential
Code metrics essentially allows us to view, at a high level, data about our code.
By reviewing this data, we can make qualitative decisions about areas that could be of concern and require additional examination
We often refer to this as looking for code smells http://en.wikipedia.org/wiki/Code_smell (Refactoring Context)
S.O.L.I.D violation Indicator using Software Metrics (Measurement)
Maintainability Index If score between 0 – 9 it could be indicate S.O.L.I.D violation
Cyclomatic Complexity If score more than 30 on member level or more than 80 on type
level it could be indicate OCP violation or SRP violation Class Coupling
If score more than 25 it could be indicate OCP violation, LSP violation, ISP violation, or DIP violation
Depth of Inheritance If score more than 4 it could be indicate OCP violation or LSP
violation Lines of Code
If code line is zero than better to cleanup the code If code more than 20 lines it could be indicate SRP violation
Code Metrics on Web Application
Code Metric in Action
Open Web Application Project on Visual Studio.
What Next
“After we examine the violation so we need to Refactoring the code.”
References
http://sourcemaking.com/refactoring https://codemetricsviewer.wordpress.com/20
11/06/26/how-to-interpret-received-results/
http://blogs.msdn.com/b/zainnab/archive/2011/05/10/code-metrics-calculating-metrics.aspx
http://en.wikipedia.org/wiki/Software_metric http://
en.wikipedia.org/wiki/Cyclomatic_complexity http://
www.codeproject.com/Articles/442514/Tool-Code-Metrics-Viewer-extension-for-Visual-Stud
http://en.wikipedia.org/wiki/Code_refactoring