sniff solid principle violation using code metrics

7
By Freddy Munandar Homework of Agile Principles, Patterns and Practices (by Uncle Bob)

Upload: freddy-munandar

Post on 17-Aug-2015

16 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Sniff SOLID Principle Violation using Code Metrics

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

Page 2: Sniff SOLID Principle Violation using Code Metrics

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 Principle Violation using Code Metrics

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 Principle Violation using Code Metrics
Page 5: Sniff SOLID Principle Violation using Code Metrics

Open Web Application Project on Visual Studio.

Page 6: Sniff SOLID Principle Violation using Code Metrics

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

Page 7: Sniff SOLID Principle Violation using Code Metrics

http://sourcemaking.com/refactoring https://codemetricsviewer.wordpress.com/2011/

06/26/how-to-interpret-received-results/ http://blogs.msdn.com/b/zainnab/archive/2011/0

5/10/code-metrics-calculating-metrics.aspx http://en.wikipedia.org/wiki/Software_metric http://en.wikipedia.org/wiki/Cyclomatic_comple

xity http://www.codeproject.com/Articles/442514/To

ol-Code-Metrics-Viewer-extension-for-Visual-Stud

http://en.wikipedia.org/wiki/Code_refactoring