sniff solid violation using code metric visual studio

7
Sniff S.O.L.I.D violation using Code Metrics Visual Studio By Freddy Munandar Homework of Agile Principles, Patterns and Practices (by Uncle Bob)

Upload: freddy-munandar

Post on 15-Aug-2015

27 views

Category:

Software


5 download

TRANSCRIPT

Page 1: Sniff SOLID violation using Code Metric Visual Studio

Sniff S.O.L.I.D violation using Code Metrics Visual Studio

By Freddy MunandarHomework of Agile Principles, Patterns and Practices (by Uncle Bob)

Page 2: Sniff SOLID violation using Code Metric Visual Studio

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)

Page 3: Sniff SOLID violation using Code Metric Visual Studio

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

Page 4: Sniff SOLID violation using Code Metric Visual Studio

Code Metrics on Web Application

Page 5: Sniff SOLID violation using Code Metric Visual Studio

Code Metric in Action

Open Web Application Project on Visual Studio.

Page 6: Sniff SOLID violation using Code Metric Visual Studio

What Next

“After we examine the violation so we need to Refactoring the code.”

Page 7: Sniff SOLID violation using Code Metric Visual Studio

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