Your SlideShare is downloading.
×

Text the download link to your phone

Standard text messaging rates apply

Like this presentation? Why not share!

- Class graph neo4j and software metrics by jexp 1171 views
- Software Metrics by Massimo Felici 6077 views
- Chapter 6 software metrics by Abhinav Shahu 3274 views
- CodeClub - Teaching the young gener... by Sebastian Marek 432 views
- Praktyczne code reviews - PHPConPl by Sebastian Marek 3386 views
- Quality Initiatives Iso 9001 2000[1] by ANNA UNIVERSITY 2610 views

6,642

Published on

We use static code analysis tools more often these days that create great reports and funky graphs. But do we understand what it all mean? …

We use static code analysis tools more often these days that create great reports and funky graphs. But do we understand what it all mean?

Software metrics tends to be magic numbers for a lot of people, but they don't really have to be. Let me introduce you to a few basic and

most popular software metric and tools and explain you what they mean and how you can use them to produce better software.

Published in:
Technology

No Downloads

Total Views

6,642

On Slideshare

0

From Embeds

0

Number of Embeds

6

Shares

0

Downloads

81

Comments

0

Likes

6

No embeds

No notes for slide

- 1. Magic behind the numbers<br />Software metrics in practice<br />Sebastian Marek, Software Architect<br />
- 2. @proofek<br /><ul><li>a Pole living in Sheffield
- 3. over 10 years PHP experience
- 4. co-author of 2 PHP books
- 5. big fan of process automation
- 6. TDD and CI
- 7. occasionally contributes to open source projects
- 8. wants to be a knight</li></li></ul><li>Agenda<br />What I will be talking about<br /><ul><li>Code metrics
- 9. Design metrics</li></ul>What I will not be talking about<br /><ul><li>Project metrics</li></li></ul><li>Most effective code quality measure<br />
- 10.
- 11. “It is the mapping of a particular characteristic of a measured entity to a numerical value”<br />Source: Object-Oriented Metrics in Practice<br />What is a metric?<br />
- 12. “Good design quality metrics are not necessarily indicative of good designs. Likewise, bad design quality metrics are not necessarily indicative of bad designs”<br />Source: JdependDocs<br />Software design<br />
- 13. System maintenance <br /><ul><li>Obsolete documentation
- 14. Convoluted design
- 15. Intensive patch mechanism (hacking)
- 16. Large size
- 17. Severe duplication
- 18. Obsolete parts (dead code)
- 19. Long build times
- 20. Loss of original developers</li></li></ul><li>Simple metrics<br /><ul><li>CLOC – comment lines of code
- 21. ELOC – executable lines of code
- 22. LOC – lines of code
- 23. NCLOC – non comment lines of code
- 24. NOP – number of packages
- 25. NOC – number of classes
- 26. NOM – number of methods
- 27. CYCLO – cyclomatic complexity number</li></li></ul><li>phploc<br />phploc 1.6.1 by Sebastian Bergmann.<br />Directories: 6<br />Files: 20<br />Lines of Code (LOC): 5478<br />Cyclomatic Complexity / Lines of Code: 0.13<br />Comment Lines of Code (CLOC): 2143<br />Non-Comment Lines of Code (NCLOC): 3335<br />Namespaces: 0<br />Interfaces: 1<br />Classes: 18<br /> Abstract: 2 (11.11%)<br /> Concrete: 16 (88.89%)<br /> Average Class Length (NCLOC): 191<br />Methods: 151<br /> Scope:<br /> Non-Static: 143 (94.70%)<br /> Static: 8 (5.30%)<br /> Visibility:<br /> Public: 116 (76.82%)<br /> Non-Public: 35 (23.18%)<br /> Average Method Length (NCLOC): 22<br />Cyclomatic Complexity / Number of Methods: 3.72<br />Anonymous Functions: 0<br />Functions: 2<br />Constants: 4<br /> Global constants: 3<br /> Class constants: 1<br />
- 28. JAVA<br />Source: Object-Oriented Metrics in Practice (based on 45 Java projects)<br />
- 29. C++<br />Source: Object-Oriented Metrics in Practice (based on 37 C++ projects)<br />
- 30. WMC and AMW<br />Weighted Method Count – total complexity of a class<br />Average Method Weight – average complexity of a method<br />
- 31. JAVA<br />Source: Object-Oriented Metrics in Practice (based on 45 Java projects)<br />
- 32. C++<br />Source: Object-Oriented Metrics in Practice (based on 37 C++ projects)<br />
- 33. Coverage report<br />
- 34.
- 35. C.R.A.P<br />
- 36. C.R.A.P<br />Change<br />Risk<br />Analysis and <br />Predictions<br />Change Risk Analysis and Predictions<br />
- 37. C.R.A.P formula<br />Code coverage = 100%<br />Code coverage = 0%<br />
- 38. Cyclomatic Complexity<br />Cyclomatic complexity measures the amount of decision logic in a single software module.<br />
- 39. Cyclomatic Complexity Number (CCN)<br />Conditional statements:<br /><ul><li>?
- 40. case
- 41. elseif
- 42. for
- 43. foreach
- 44. if
- 45. while</li></li></ul><li>CCN2<br />Conditional statements:<br /><ul><li>?
- 46. case
- 47. elseif
- 48. for
- 49. foreach
- 50. if
- 51. while
- 52. &&
- 53. ||
- 54. or
- 55. and
- 56. xor</li></li></ul><li>Cyclomatic complexity<br />Conditional statements:<br /><ul><li>?
- 57. case
- 58. elseif
- 59. for
- 60. foreach
- 61. if
- 62. while
- 63. &&
- 64. ||
- 65. or
- 66. and
- 67. xor
- 68. catch</li></li></ul><li>Cyclomatic complexity - example<br />
- 69. Cyclomatic complexity - example<br />
- 70. Cyclomatic complexity - example<br />
- 71. Cyclomatic complexity - example<br />
- 72. Cyclomatic complexity - example<br />
- 73. Cyclomatic complexity - example<br />
- 74. Cyclomatic complexity - example<br />
- 75. Cyclomatic complexity - example<br />
- 76. NPATH – acyclic execution path complexity<br />NPATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested<br />Edgar H. Sibley<br />
- 77. NPATH – acyclic execution path complexity<br />expressions Number of && and || operators in expression<br />if NP(<if-range>)+NP(<expr>)+1<br /> if-else NP(<if-range>)+NP(<else-range>)+NP(<expr>)<br />while NP(<while-range>)+NP(<expr>)+1<br />for NP(<for-range>)+NP(<expr1>)+NP(<expr2>)+<br /> NP(<expr3>)+1<br />break 1<br /> continue 1<br /> return 1<br /> sequential 1<br />function call 1<br />
- 78. NPATH – example<br />
- 79. NPATH – example<br />
- 80. NPATH – example<br />
- 81. NPATH – example<br />
- 82. NPATH – example<br />
- 83. NPATH – example<br />
- 84. NPATH – example<br />
- 85. NPATH – example<br />
- 86. NPATH – example<br />
- 87. NPATH – example<br />
- 88. NPATH – example<br />
- 89. NPATH – example<br />
- 90. NPATH – example<br />
- 91. NPATH – example<br />
- 92. NPATH – example<br />
- 93. NPATH – example<br />
- 94. NPATH – example<br />
- 95. NPATH – example<br />
- 96. NPATH – example<br />
- 97. PHP Depend<br />PHP_Depend 0.10.6 by Manuel Pichler<br />Parsing source files:<br />.................... 20<br />Executing CyclomaticComplexity-Analyzer:<br />............. 261<br />Executing ClassLevel-Analyzer:<br />............ 247<br />Executing CodeRank-Analyzer:<br />. 28<br />Executing Coupling-Analyzer:<br />............. 267<br />Executing Hierarchy-Analyzer:<br />............ 246<br />Executing Inheritance-Analyzer:<br />. 30<br />Executing NPathComplexity-Analyzer:<br />.............. 283<br />Executing NodeCount-Analyzer:<br />........ 174<br />Executing NodeLoc-Analyzer:<br />.......... 205<br />Generating pdepend log files, this may take a moment.<br />Time: 00:05; Memory: 25.50Mb<br />
- 98. PHP Mess Detector<br />
- 99. Overview pyramid<br />
- 100. Size and complexity – direct metrics<br />
- 101. Size and complexity – computed proportions<br />
- 102. System coupling – direct metrics<br />
- 103. System coupling – computed proportions<br />
- 104. System inheritance<br />
- 105. Complete Overview Pyramid<br />
- 106. PHP<br />http://pdepend.org/<br />
- 107. Metrics visualisation with Sonar<br />
- 108. Metrics visualisation with Sonar<br />
- 109. Violations reporting<br />
- 110. SIG Maintainability Model<br />--<br />-<br />0<br />+<br />++<br />Very bad<br />Bad<br />Average<br />Good<br />Very good<br />
- 111. Technical Debt<br />
- 112. Summary<br />“We believe that software metrics, in general, are just tools. No single metric can tell the whole story; it’s just one more data point. “<br />“Metrics are meant to be used by developers, not the other way around – the metric should work for you, you should not have to work for the metric. “<br />“Metrics should never be an end unto themselves. Metrics are meant to help you think, not to do the thinking for you.”<br />Alberto Savoia<br />
- 113. Resources<br /><ul><li>PHP Depend - http://pdepend.org/
- 114. PHP Mess Detector - http://phpmd.org/
- 115. Manuel’s home page - http://manuel-pichler.de/
- 116. PHPUnit - http://www.phpunit.de/
- 117. phploc- http://sebastianbergmann.github.com/phploc/
- 118. Sonar - http://www.sonarsource.org/
- 119. “Object-Oriented Metrics in Practice” by Michele Lanzaand RaduMarinescu (ISBN 978-3540244295)</li></li></ul><li>Questions<br />Questions?<br /> http://joind.in/3588<br />

Be the first to comment