SlideShare a Scribd company logo
1 of 52
Download to read offline
Magic	
  behind	
  the	
  numbers	
  
	
  

So.ware	
  metrics	
  in	
  prac&ce	
  




Sebas&an	
  Marek,	
  So.ware	
  Architect	
  
•  a	
  Pole	
  living	
  in	
  Sheffield	
  
    •  over	
  12	
  years	
  in	
  
       development	
  
    •  Pascal,	
  C++,	
  PHP,	
  perl,	
  
       python,	
  Java	
  
    •  co-­‐author	
  of	
  2	
  PHP	
  books	
  	
  
    •  big	
  fan	
  of	
  process	
  
       automa&on	
  
    •  TDD	
  and	
  CI	
  
    •  occasionally	
  contributes	
  to	
  
       open	
  source	
  projects	
  
    •  wants	
  to	
  be	
  a	
  knight	
  




@proofek	
  
• What	
  I	
  will	
  be	
  talking	
  about	
  
    •  Code	
  metrics	
  
    •  Design	
  metrics	
  

    • What	
  I	
  will	
  not	
  be	
  talking	
  about	
  
    •  Project	
  metrics	
  




Agenda	
  
Most	
  effec&ve	
  code	
  quality	
  measure	
  
“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?	
  
“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



So.ware	
  design	
  
•  Obsolete	
  documenta&on	
  

                                •  Convoluted	
  design	
  

                                •  Intensive	
  patch	
  mechanism	
  
                                   (hacking)	
  

                                •  Large	
  size	
  

                                •  Severe	
  duplica&on	
  

                                •  Obsolete	
  parts	
  (dead	
  code)	
  

                                •  Long	
  build	
  &mes	
  

                                •  Loss	
  of	
  original	
  developers	
  

System	
  maintenance	
  	
  
•  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	
  



Simple	
  metrics	
  
Cyclomatic complexity measures
                 the amount of decision logic
                 in a single software module




Cycloma&c	
  Complexity	
  (CYCLO)	
  
Condi3onal	
  statements:	
  
     	
  
     •  ?	
  
     •  case	
  
     •  elseif	
  
     •  for	
  
     •  foreach	
  
     •  if	
  
     •  while	
  




Cycloma&c	
  Complexity	
  Number	
  (CCN)	
  
Condi3onal	
  statements:	
  
     	
  
     •  ?	
                          •    &&	
  
     •  case	
  
                                     •    ||	
  
     •  elseif	
  
     •  for	
                        •    or	
  
     •  foreach	
                    •    and	
  
     •  if	
                         •    xor	
  
     •  while	
  




CCN2	
  
Condi3onal	
  statements:	
  
    	
  
    •  ?	
                          •    &&	
  
    •  case	
  
                                    •    ||	
  
    •  elseif	
  
    •  for	
                        •    or	
  
    •  foreach	
                    •    and	
  
    •  if	
                         •    xor	
  
    •  while	
                      •    catch	
  




Cycloma&c	
  Complexity	
  
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();
        }
    }
}


Cycloma&c	
  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();
        }
    }
}


Cycloma&c	
  complexity	
  -­‐	
  example	
  
phploc 1.6.1 by Sebastian Bergmann.	
	
Directories:                                         6	
Files:                                              20	
	
Lines of Code (LOC):                              5478	
     Cyclomatic Complexity / Lines of Code:       0.13	
Comment Lines of Code (CLOC):                     2143	
Non-Comment Lines of Code (NCLOC):                3335	
	
Namespaces:                                          0	
Interfaces:                                          1	
Classes:                                            18	
     Abstract:                                       2 (11.11%)	
     Concrete:                                      16 (88.89%)	
     Average Class Length (NCLOC):                 191	
Methods:                                           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:                                 0	
Functions:                                           2	
	
Constants:                                           4	
     Global constants:                               3	
     Class constants:                                1	
	
  




phploc	
  
Low	
           Avg	
       High	
       V.High	
  
     Complexity	
              1-­‐4	
         5-­‐7	
     8-­‐10	
     >	
  11	
  




Cycloma&c	
  complexity	
  -­‐	
  thresholds	
  
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	
  Prac5ce	
  (based	
  on	
  45	
  Java	
  projects)	
  




JAVA	
  
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	
  Prac5ce	
  (based	
  on	
  37	
  C++	
  projects)	
  




C++	
  
Weighted	
  Method	
  Count	
  –	
  total	
  complexity	
  of	
  a	
  class	
  




    Average	
  Method	
  Weight	
  –	
  average	
  complexity	
  of	
  a	
  method	
  




WMC	
  and	
  AMW	
  
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	
  Prac5ce	
  (based	
  on	
  45	
  Java	
  projects)	
  




JAVA	
  
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	
  Prac5ce	
  (based	
  on	
  37	
  C++	
  projects)	
  




C++	
  
Coverage	
  report	
  
Coverage	
  report	
  
C.R.A.P	
  
Change	
  
              Risk	
  
              Analysis	
  and	
  	
  
              Predic&ons	
  

C.R.A.P	
  
Code	
  coverage	
  =	
  100%	
  




                          Code	
  coverage	
  =	
  0%	
  




C.R.A.P	
  formula	
  
C.R.A.P	
  thresholds	
  
“NPATH is an objective measure of
                 software complexity related to
                  the ease with which software
                 can be comprehensively tested”

                                                              Edgar H. Sibley




NPATH	
  –	
  acyclic	
  execu&on	
  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	


NPATH	
  –	
  acyclic	
  execu&on	
  path	
  complexity	
  
class 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;
      }
}


NPATH	
  –	
  example	
  
class Foo {
    public function example() {

            if ($a == $b) {
                if ($a1 == $b1) {
                    fiddle();
                } else {                        3
                    fiddle();
                }
            }

            if ($e == $f && $g == $z) {
                for ($n = 0; $n < $h; $n++) {
                    fiddle();                   4
                }
            }

            return true;                        1
      }
}


NPATH	
  –	
  example	
  
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	
  




PHP	
  Depend	
  
PHP	
  Mess	
  Detector	
  
Overview	
  pyramid	
  
Size	
  and	
  complexity	
  –	
  direct	
  metrics	
  
Size	
  and	
  complexity	
  –	
  computed	
  propor&ons	
  
System	
  coupling	
  –	
  direct	
  metrics	
  
System	
  coupling	
  –	
  computed	
  propor&ons	
  
System	
  inheritance	
  
Complete	
  Overview	
  Pyramid	
  
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	
  

                                                   hBp://pdepend.org/	
  




PHP	
  
Metrics	
  visualisa&on	
  with	
  Sonar	
  
Metrics	
  visualisa&on	
  with	
  Sonar	
  
Viola&ons	
  repor&ng	
  
-­‐-­‐	
     Very	
  bad	
  
    -­‐	
        Bad	
  
    0	
          Average	
  
    +	
          Good	
  
    ++	
         Very	
  good	
  
    	
  


SIG	
  Maintainability	
  Model	
  
Technical	
  Debt	
  
“We	
  believe	
  that	
  soIware	
  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	
  




Summary	
  
•    PHP	
  Depend	
  -­‐	
  hmp://pdepend.org/	
  
    •    PHP	
  Mess	
  Detector	
  -­‐	
  hmp://phpmd.org/	
  
    •    Manuel’s	
  home	
  page	
  -­‐	
  hmp://manuel-­‐pichler.de/	
  
    •    PHPUnit	
  -­‐	
  hmp://www.phpunit.de/	
  
    •    phploc	
  -­‐	
  hmp://sebas&anbergmann.github.com/phploc/	
  
    •    Sonar	
  -­‐	
  hmp://www.sonarsource.org/	
  




Resources	
  
“Object-­‐Oriented	
  Metrics	
  in	
  Prac&ce”	
  by	
  Michele	
  Lanza	
  and	
  
                   Radu	
  Marinescu	
  (ISBN	
  978-­‐3540244295)	
  
                                                	
  




Object-­‐Oriented	
  Metrics	
  in	
  Prac&ce	
  
•      hmp://www.flickr.com/photos/romainguy/102073478/	
  
     •      hmp://www.flickr.com/photos/shanafin/615680234/	
  
     •      hmp://www.flickr.com/photos/pahudson/3080270873/	
  
     •      hmp://www.flickr.com/photos/smohundro/2243554264/	
  
     •      hmp://www.flickr.com/photos/m_a_melendez/5956157581/	
  
     •      hmp://www.flickr.com/photos/elkit/7182541802/	
  
     •      hmp://www.flickr.com/photos/rickyromero/4209571303/	
  
     	
  




Thanks	
  to…	
  
Ques&ons?	
  

                hmps://joind.in/6445	
  




Ques&ons?	
  

More Related Content

What's hot

Detecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchDetecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchShinpei Hayashi
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio
 
JavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонкеJavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонкеFestGroup
 
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...Thanos Zolotas
 
NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#tcaesvk
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Raimon Ràfols
 
C++ exception handling
C++ exception handlingC++ exception handling
C++ exception handlingRay Song
 
Ridge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisRidge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisPriyanka Aash
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab reportJinesh Kb
 
Rails Code Club 2 @ Taipei
Rails Code Club 2 @ TaipeiRails Code Club 2 @ Taipei
Rails Code Club 2 @ TaipeiBruce Li
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsJan Aerts
 

What's hot (20)

Detecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchDetecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic Search
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
javarmi
javarmijavarmi
javarmi
 
PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 project
 
JavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонкеJavaFest. Виктор Полищук. Legacy: как победить в гонке
JavaFest. Виктор Полищук. Legacy: как победить в гонке
 
Behavioral modelling in VHDL
Behavioral modelling in VHDLBehavioral modelling in VHDL
Behavioral modelling in VHDL
 
clang-intro
clang-introclang-intro
clang-intro
 
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...
Bridging Proprietary Modelling and Open-Source Model Management Tools: The Ca...
 
NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#NDC 2011, C++ 프로그래머를 위한 C#
NDC 2011, C++ 프로그래머를 위한 C#
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
C++ exception handling
C++ exception handlingC++ exception handling
C++ exception handling
 
Ridge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisRidge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power Analysis
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
Extending and scripting PDT
Extending and scripting PDTExtending and scripting PDT
Extending and scripting PDT
 
Java 10, Java 11 and beyond
Java 10, Java 11 and beyondJava 10, Java 11 and beyond
Java 10, Java 11 and beyond
 
Lab9 processos
Lab9 processosLab9 processos
Lab9 processos
 
Rails Code Club 2 @ Taipei
Rails Code Club 2 @ TaipeiRails Code Club 2 @ Taipei
Rails Code Club 2 @ Taipei
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 

Similar to PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice

Rails Software Metrics
Rails Software MetricsRails Software Metrics
Rails Software Metricschiel
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedDennis de Greef
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzIvan Krylov
 
Lifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeLifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeJ On The Beach
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaWei-Bo Chen
 
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...Roberto Pepato
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)Felix Geisendörfer
 
Object Detection with Transformers
Object Detection with TransformersObject Detection with Transformers
Object Detection with TransformersDatabricks
 
Metrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMetrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMax Kleiner
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdbWei-Bo Chen
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP StackLorna Mitchell
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseAndrew Eisenberg
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel modecorehard_by
 
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...David Beazley (Dabeaz LLC)
 
NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend
 
Testing multithreaded java applications for synchronization problems
Testing multithreaded java applications for synchronization problemsTesting multithreaded java applications for synchronization problems
Testing multithreaded java applications for synchronization problemsVassil Popovski
 

Similar to PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice (20)

Rails Software Metrics
Rails Software MetricsRails Software Metrics
Rails Software Metrics
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explained
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
 
Lifecycle of a JIT compiled code
Lifecycle of a JIT compiled codeLifecycle of a JIT compiled code
Lifecycle of a JIT compiled code
 
Triton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON ChinaTriton and Symbolic execution on GDB@DEF CON China
Triton and Symbolic execution on GDB@DEF CON China
 
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...
Continuous Inspection - Uma abordagem efetiva para melhoria contínua da quali...
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019
 
Object Detection with Transformers
Object Detection with TransformersObject Detection with Transformers
Object Detection with Transformers
 
Metrics ekon 14_2_kleiner
Metrics ekon 14_2_kleinerMetrics ekon 14_2_kleiner
Metrics ekon 14_2_kleiner
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
Tool up your lamp stack
Tool up your lamp stackTool up your lamp stack
Tool up your lamp stack
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP Stack
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL Support
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-Eclipse
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
 
NDepend Public PPT (2008)
NDepend Public PPT (2008)NDepend Public PPT (2008)
NDepend Public PPT (2008)
 
Code metrics in PHP
Code metrics in PHPCode metrics in PHP
Code metrics in PHP
 
Testing multithreaded java applications for synchronization problems
Testing multithreaded java applications for synchronization problemsTesting multithreaded java applications for synchronization problems
Testing multithreaded java applications for synchronization problems
 

More from Sebastian Marek

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationSebastian Marek
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingSebastian Marek
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlSebastian Marek
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application PerformanceSebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerSebastian Marek
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Sebastian Marek
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceSebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerSebastian Marek
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice Sebastian Marek
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnitSebastian Marek
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferSebastian Marek
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them allSebastian Marek
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking Sebastian Marek
 

More from Sebastian Marek (15)

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous Integration
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programming
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPl
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application Performance
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practice
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_Codesniffer
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them all
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice

  • 1. Magic  behind  the  numbers     So.ware  metrics  in  prac&ce   Sebas&an  Marek,  So.ware  Architect  
  • 2. •  a  Pole  living  in  Sheffield   •  over  12  years  in   development   •  Pascal,  C++,  PHP,  perl,   python,  Java   •  co-­‐author  of  2  PHP  books     •  big  fan  of  process   automa&on   •  TDD  and  CI   •  occasionally  contributes  to   open  source  projects   •  wants  to  be  a  knight   @proofek  
  • 3. • What  I  will  be  talking  about   •  Code  metrics   •  Design  metrics   • What  I  will  not  be  talking  about   •  Project  metrics   Agenda  
  • 4. Most  effec&ve  code  quality  measure  
  • 5.
  • 6. “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?  
  • 7. “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 So.ware  design  
  • 8. •  Obsolete  documenta&on   •  Convoluted  design   •  Intensive  patch  mechanism   (hacking)   •  Large  size   •  Severe  duplica&on   •  Obsolete  parts  (dead  code)   •  Long  build  &mes   •  Loss  of  original  developers   System  maintenance    
  • 9. •  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   Simple  metrics  
  • 10. Cyclomatic complexity measures the amount of decision logic in a single software module Cycloma&c  Complexity  (CYCLO)  
  • 11. Condi3onal  statements:     •  ?   •  case   •  elseif   •  for   •  foreach   •  if   •  while   Cycloma&c  Complexity  Number  (CCN)  
  • 12. Condi3onal  statements:     •  ?   •  &&   •  case   •  ||   •  elseif   •  for   •  or   •  foreach   •  and   •  if   •  xor   •  while   CCN2  
  • 13. Condi3onal  statements:     •  ?   •  &&   •  case   •  ||   •  elseif   •  for   •  or   •  foreach   •  and   •  if   •  xor   •  while   •  catch   Cycloma&c  Complexity  
  • 14. 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(); } } } Cycloma&c  complexity  -­‐  example  
  • 15. 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(); } } } Cycloma&c  complexity  -­‐  example  
  • 16. phploc 1.6.1 by Sebastian Bergmann. Directories: 6 Files: 20 Lines of Code (LOC): 5478 Cyclomatic Complexity / Lines of Code: 0.13 Comment Lines of Code (CLOC): 2143 Non-Comment Lines of Code (NCLOC): 3335 Namespaces: 0 Interfaces: 1 Classes: 18 Abstract: 2 (11.11%) Concrete: 16 (88.89%) Average Class Length (NCLOC): 191 Methods: 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: 0 Functions: 2 Constants: 4 Global constants: 3 Class constants: 1   phploc  
  • 17. Low   Avg   High   V.High   Complexity   1-­‐4   5-­‐7   8-­‐10   >  11   Cycloma&c  complexity  -­‐  thresholds  
  • 18. 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  Prac5ce  (based  on  45  Java  projects)   JAVA  
  • 19. 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  Prac5ce  (based  on  37  C++  projects)   C++  
  • 20. Weighted  Method  Count  –  total  complexity  of  a  class   Average  Method  Weight  –  average  complexity  of  a  method   WMC  and  AMW  
  • 21. 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  Prac5ce  (based  on  45  Java  projects)   JAVA  
  • 22. 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  Prac5ce  (based  on  37  C++  projects)   C++  
  • 26. Change   Risk   Analysis  and     Predic&ons   C.R.A.P  
  • 27. Code  coverage  =  100%   Code  coverage  =  0%   C.R.A.P  formula  
  • 29. “NPATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested” Edgar H. Sibley NPATH  –  acyclic  execu&on  path  complexity  
  • 30. 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 NPATH  –  acyclic  execu&on  path  complexity  
  • 31. class 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; } } NPATH  –  example  
  • 32. class Foo { public function example() { if ($a == $b) { if ($a1 == $b1) { fiddle(); } else { 3 fiddle(); } } if ($e == $f && $g == $z) { for ($n = 0; $n < $h; $n++) { fiddle(); 4 } } return true; 1 } } NPATH  –  example  
  • 33. 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   PHP  Depend  
  • 36. Size  and  complexity  –  direct  metrics  
  • 37. Size  and  complexity  –  computed  propor&ons  
  • 38. System  coupling  –  direct  metrics  
  • 39. System  coupling  –  computed  propor&ons  
  • 42. 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   hBp://pdepend.org/   PHP  
  • 46. -­‐-­‐   Very  bad   -­‐   Bad   0   Average   +   Good   ++   Very  good     SIG  Maintainability  Model  
  • 48. “We  believe  that  soIware  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   Summary  
  • 49. •  PHP  Depend  -­‐  hmp://pdepend.org/   •  PHP  Mess  Detector  -­‐  hmp://phpmd.org/   •  Manuel’s  home  page  -­‐  hmp://manuel-­‐pichler.de/   •  PHPUnit  -­‐  hmp://www.phpunit.de/   •  phploc  -­‐  hmp://sebas&anbergmann.github.com/phploc/   •  Sonar  -­‐  hmp://www.sonarsource.org/   Resources  
  • 50. “Object-­‐Oriented  Metrics  in  Prac&ce”  by  Michele  Lanza  and   Radu  Marinescu  (ISBN  978-­‐3540244295)     Object-­‐Oriented  Metrics  in  Prac&ce  
  • 51. •  hmp://www.flickr.com/photos/romainguy/102073478/   •  hmp://www.flickr.com/photos/shanafin/615680234/   •  hmp://www.flickr.com/photos/pahudson/3080270873/   •  hmp://www.flickr.com/photos/smohundro/2243554264/   •  hmp://www.flickr.com/photos/m_a_melendez/5956157581/   •  hmp://www.flickr.com/photos/elkit/7182541802/   •  hmp://www.flickr.com/photos/rickyromero/4209571303/     Thanks  to…  
  • 52. Ques&ons?   hmps://joind.in/6445   Ques&ons?