magic behind the numbers - software metrics in practice
TRANSCRIPT
![Page 1: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/1.jpg)
Sebastian Marek, Software Architect
Magic behind the numbers
Software metrics in
practice
![Page 2: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/2.jpg)
@proofek
• a Pole living in Sheffield• over 10 years PHP
experience• co-author of 2 PHP books • big fan of process
automation• TDD and CI• occasionally contributes
to open source projects• wants to be a knight
![Page 3: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/3.jpg)
Agenda
What I will be talking about• Code metrics• Design metrics
What I will not be talking about• Project metrics
![Page 4: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/4.jpg)
Most effective code quality measure
![Page 5: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/5.jpg)
![Page 6: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/6.jpg)
“It is the mapping of a particular characteristic of a measured entity to
a numerical value”
Source: Object-Oriented Metrics in Practice
What is a metric?
![Page 7: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/7.jpg)
“Good design quality metrics are not necessarily indicative of good designs. Likewise, bad design quality metrics are not necessarily indicative of bad
designs”
Source: Jdepend Docs
Software design
![Page 8: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/8.jpg)
System maintenance
• Obsolete documentation• Convoluted design• Intensive patch mechanism (hacking)• Large size• Severe duplication• Obsolete parts (dead code)• Long build times• Loss of original developers
![Page 9: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/9.jpg)
Simple metrics
• CLOC – comment lines of code• ELOC – executable lines of code• LOC – lines of code• NCLOC – non comment lines of code• NOP – number of packages• NOC – number of classes• NOM – number of methods• CYCLO – cyclomatic complexity number
![Page 10: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/10.jpg)
phploc
phploc 1.6.1 by Sebastian Bergmann.
Directories: 6Files: 20
Lines of Code (LOC): 5478 Cyclomatic Complexity / Lines of Code: 0.13Comment Lines of Code (CLOC): 2143Non-Comment Lines of Code (NCLOC): 3335
Namespaces: 0Interfaces: 1Classes: 18 Abstract: 2 (11.11%) Concrete: 16 (88.89%) Average Class Length (NCLOC): 191Methods: 151 Scope: Non-Static: 143 (94.70%) Static: 8 (5.30%) Visibility: Public: 116 (76.82%) Non-Public: 35 (23.18%) Average Method Length (NCLOC): 22 Cyclomatic Complexity / Number of Methods: 3.72
Anonymous Functions: 0Functions: 2
Constants: 4 Global constants: 3 Class constants: 1
![Page 11: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/11.jpg)
JAVA
Metric Low Avg High V.High
CYCLO/Line of code 0.16 0.20 0.24 0.36
LOC/Method 7 10 13 19.5
NOM/Class 4 7 10 15
Source: Object-Oriented Metrics in Practice (based on 45 Java projects)
![Page 12: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/12.jpg)
C++
Metric Low Avg High V.High
CYCLO/Line of code 0.20 0.25 0.30 0.45
LOC/Method 5 10 16 24
NOM/Class 4 9 15 22.5
Source: Object-Oriented Metrics in Practice (based on 37 C++ projects)
![Page 13: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/13.jpg)
WMC and AMW
Weighted Method Count – total complexity of a class
Average Method Weight – average complexity of a method
![Page 14: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/14.jpg)
JAVA
Metric Low Avg High V.High
WMC 5 14 31 47
AMW 1.1 2.0 3.1 4.7
LOC/Class 28 70 130 195
Source: Object-Oriented Metrics in Practice (based on 45 Java projects)
![Page 15: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/15.jpg)
C++
Metric Low Avg High V.High
WMC 4 23 72 108
AMW 1.0 2.5 4.8 7.0
LOC/Class 20 90 240 360
Source: Object-Oriented Metrics in Practice (based on 37 C++ projects)
![Page 16: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/16.jpg)
Coverage report
![Page 17: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/17.jpg)
![Page 18: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/18.jpg)
C.R.A.P
![Page 19: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/19.jpg)
C.R.A.P
Change Risk Analysis and Predictions
ChangeRiskAnalysis and Predictions
![Page 20: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/20.jpg)
C.R.A.P formula
Code coverage = 100%
Code coverage = 0%
![Page 21: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/21.jpg)
Cyclomatic Complexity
Cyclomatic complexity measures the amount of decision logic in a single software
module.
![Page 22: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/22.jpg)
Cyclomatic Complexity Number (CCN)
Conditional statements:• ?• case• elseif• for• foreach• if• while
![Page 23: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/23.jpg)
CCN2
Conditional statements:• ?• case• elseif• for• foreach• if• while
• &&• ||• or• and• xor
![Page 24: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/24.jpg)
Cyclomatic complexity
Conditional statements:• ?• case• elseif• for• foreach• if• while
• &&• ||• or• and• xor• catch
![Page 25: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/25.jpg)
Cyclomatic complexity - example
class Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
} elseif ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 26: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/26.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
} elseif ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 27: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/27.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) { 2 if ($a1 == $b1) {
fiddle();
} elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
} elseif ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 28: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/28.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) { 2 if ($a1 == $b1) { 3 fiddle();
} elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
} elseif ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 29: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/29.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) { 2 if ($a1 == $b1) { 3 fiddle();
} elseif ($a2 == $b2) { 4 fiddle();
} else {
fiddle();
}
} elseif ($e == $f) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 30: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/30.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) { 2 if ($a1 == $b1) { 3 fiddle();
} elseif ($a2 == $b2) { 4 fiddle();
} else {
fiddle();
}
} elseif ($e == $f) { 5 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
fiddle();
}
}
}
![Page 31: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/31.jpg)
Cyclomatic complexity - example
class Foo {
public function example() { 1 if ($a == $b) { 2 if ($a1 == $b1) { 3 fiddle();
} elseif ($a2 == $b2) { 4 fiddle();
} else {
fiddle();
}
} elseif ($e == $f) { 5 for ($n = 0; $n < $h; $n++) { 6 fiddle();
}
} else {
fiddle();
}
}
}
![Page 32: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/32.jpg)
Cyclomatic complexity - example
class Foo {
public function example() {
6
if ($a == $b) { if ($a1 == $b1) { fiddle(); } elseif ($a2 == $b2) { fiddle(); } else { fiddle(); } } elseif ($e == $f) { for ($n = 0; $n < $h; $n++) { fiddle(); } } else { fiddle(); } }}
![Page 33: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/33.jpg)
NPATH – acyclic execution path complexity
NPATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested
Edgar H. Sibley
![Page 34: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/34.jpg)
NPATH – acyclic execution path complexity
expressions Number of && and || operators in expression if NP(<if-range>)+NP(<expr>)+1 if-else NP(<if-range>)+NP(<else-range>)+NP(<expr>) while NP(<while-range>)+NP(<expr>)+1 for NP(<for-range>)+NP(<expr1>)+NP(<expr2>)+ NP(<expr3>)+1
break 1 continue 1 return 1 sequential 1 function call 1
![Page 35: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/35.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle();
} else {
fiddle();
}
}
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 36: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/36.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle(); 1 } else {
fiddle();
}
}
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 37: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/37.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
fiddle(); 1 } else {
fiddle(); 2 }
}
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 38: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/38.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) { 2 fiddle(); 1 } else {
fiddle(); 2 }
}
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 39: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/39.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
2 fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 40: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/40.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
if ($a1 == $b1) {
2 fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 41: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/41.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) { 2 if ($a1 == $b1) {
2 fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 42: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/42.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) { 2 if ($a1 == $b1) {
2 fiddle(); } else { fiddle(); } } 3
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 43: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/43.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle();
}
}
return true;
}
}
![Page 44: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/44.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {
fiddle(); 1 }
}
return true;
}
}
![Page 45: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/45.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) { 1 fiddle(); 1 }
}
return true;
}
}
![Page 46: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/46.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) { 1 fiddle(); 1 } 2 }
return true;
}
}
![Page 47: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/47.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {2 fiddle();
} }
return true;
}
}
![Page 48: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/48.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
for ($n = 0; $n < $h; $n++) {2 fiddle();
} }
return true;
}
}
![Page 49: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/49.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) { 3 for ($n = 0; $n < $h; $n++) {
2 fiddle(); } }
return true;
}
}
![Page 50: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/50.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) { 3 for ($n = 0; $n < $h; $n++) {
2 fiddle(); } } 4
return true;
}
}
![Page 51: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/51.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
4 for ($n = 0; $n < $h; $n++) { fiddle(); } }
return true;
}
}
![Page 52: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/52.jpg)
NPATH – exampleclass Foo {
public function example() {
if ($a == $b) {
3
if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) {
4 for ($n = 0; $n < $h; $n++) { fiddle(); } }
return true; 1 }
}
![Page 53: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/53.jpg)
NPATH – exampleclass Foo {
public function example() {
12
if ($a == $b) { if ($a1 == $b1) { fiddle(); } else { fiddle(); } }
if ($e == $f && $g == $z) { for ($n = 0; $n < $h; $n++) { fiddle(); } } return true; }}
![Page 54: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/54.jpg)
PHP Depend
PHP_Depend 0.10.6 by Manuel Pichler
Parsing source files:.................... 20
Executing CyclomaticComplexity-Analyzer:............. 261
Executing ClassLevel-Analyzer:............ 247
Executing CodeRank-Analyzer:. 28
Executing Coupling-Analyzer:............. 267
Executing Hierarchy-Analyzer:............ 246
Executing Inheritance-Analyzer:. 30
Executing NPathComplexity-Analyzer:.............. 283
Executing NodeCount-Analyzer:........ 174
Executing NodeLoc-Analyzer:.......... 205
Generating pdepend log files, this may take a moment.
Time: 00:05; Memory: 25.50Mb
![Page 55: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/55.jpg)
PHP Mess Detector
![Page 56: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/56.jpg)
Overview pyramid
![Page 57: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/57.jpg)
Size and complexity – direct metrics
![Page 58: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/58.jpg)
Size and complexity – computed proportions
![Page 59: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/59.jpg)
System coupling – direct metrics
![Page 60: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/60.jpg)
System coupling – computed proportions
![Page 61: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/61.jpg)
System inheritance
![Page 62: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/62.jpg)
Complete Overview Pyramid
![Page 63: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/63.jpg)
PHP
Metric Low Avg High
CYCLO/LOC 0.16 0.20 0.24
LOC/NOM 7 10 13
NOM/NOC 4 7 10
NOC/NOP 6 17 26
CALLS/NOM 2.01 2.62 3.2
FANOUT/CALLS 0.56 0.62 0.68
ANDC 0.25 0.41 0.57
AHH 0.09 0.21 0.32
http://pdepend.org/
![Page 64: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/64.jpg)
Metrics visualisation with Sonar
![Page 65: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/65.jpg)
Metrics visualisation with Sonar
![Page 66: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/66.jpg)
Violations reporting
![Page 67: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/67.jpg)
SIG Maintainability Model
---0+++
Very bad
BadAverageGoodVery good
![Page 68: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/68.jpg)
Technical Debt
![Page 69: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/69.jpg)
Summary
“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. “
“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. “
“Metrics should never be an end unto themselves. Metrics are meant to help you think, not to do the thinking for you.”
Alberto Savoia
![Page 70: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/70.jpg)
Resources
• PHP Depend - http://pdepend.org/• PHP Mess Detector - http://phpmd.org/• Manuel’s home page - http://manuel-pichler.de/• PHPUnit - http://www.phpunit.de/• phploc - http://sebastianbergmann.github.com/phploc/• Sonar - http://www.sonarsource.org/• “Object-Oriented Metrics in Practice” by Michele Lanza
and Radu Marinescu (ISBN 978-3540244295)
![Page 71: Magic behind the numbers - software metrics in practice](https://reader030.vdocuments.site/reader030/viewer/2022033100/55d52882bb61ebf6498b45a3/html5/thumbnails/71.jpg)
Questions
http://joind.in/3588
Questions?