SlideShare uma empresa Scribd logo
1 de 59
#phpday
          Dica trentatrè <?php echo ’33’ ?>
           Controllare lo stato di salute di una applicazione con le
                             metriche del codice




                                            Michele Orselli (@_orso_)
#phpday


          Code Metrics
Measure of some property of a piece
#phpday



               of software (Wikipedia)
#phpday


          Who Cares?
#phpday

          How long will it take to add feature X?
#phpday

          Internal vs External Quality
Code Metrics as a mean to expose
#phpday



                  internal quality
#phpday

          How long will it take to add feature X?
#phpday


          Classic
Lines and Numbers

          Lines
                  LOC: Lines Of Code
#phpday           ELOC: Executable LOC
                  CLOC: Comment LOC
                  NCLOC: Non-Comment LOC

          Numbers
             NOC: Number Of Classes
             NOM: Number Of Methods
             NOP: Number Of Packages
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                            5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday                     7      abstract function area();
                            8    }
                            9
                            10   class circle extends shape {
                            11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
                            16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday                     7      abstract function area();
                            8    }
                            9
                            10   class circle extends shape {
                            11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
                            16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
                            9
                            10   class circle extends shape {
                            11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
                            16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
            NCLOC 20        9
                            10   class circle extends shape {
                            11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
                            16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
            NCLOC 20        9
                            10   class circle extends shape {
               ELOC     3   11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
                            16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
            NCLOC 20        9
                            10   class circle extends shape {
               ELOC     3   11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
               NOP      1   16
                            17   class triangle extends shape {
                            18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
            NCLOC 20        9
                            10   class circle extends shape {
               ELOC     3   11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
               NOP      1   16
                            17   class triangle extends shape {
               NOC      3   18
                            19        public function area() {}
                            20   }
                            21
                            22   ?>
Lines and Numbers
                            1    <?php
                            2
           Lines            3    namespace shapestwodimensional;
                            4
                   LOC 22   5    abstract class shape {
                            6      /* Returns the area of the shape */
#phpday       CLOC      2   7      abstract function area();
                            8    }
            NCLOC 20        9
                            10   class circle extends shape {
               ELOC     3   11      public function area() {}
                            12
                            13        /* Ret the diameter of the circle */
          Numbers           14        public function diameter() {}
                            15   }
               NOP      1   16
                            17   class triangle extends shape {
               NOC      3   18
                            19        public function area() {}
               NOM      4   20   }
                            21
                            22   ?>
#phpday
                       phploc
          http://sebastianbergmann.github.com/phploc/
#phpday
#phpday


          Complexity
Complexity


#phpday
          Control Structures Complexity
           if, elseif, for, while, foreach, catch, case, xor,
           and, or, &&, ||, ?:
          Ciclomatic Complexity (CCN)
          NPath Complexity
Ciclomatic Complexity
                              1    <?php
                              2
          # decision points   3    class polygon {
                              4
                              5    public function perimeter()
                              6    {
#phpday           CCN         7        if (!is_array($this->vertices)) {
                              8            return false;
                              9        }
                              10
                              11        $perimeter = 0;
                              12
                              13        foreach ($this->vertices as $vertex) {
                              14          $perimenter += $vertex;
                              15        }
                              16
                              17        return $perimeter;
                              18        }
                              19   }
                              20   ?>
Ciclomatic Complexity
                                  1    <?php
                                  2
          # decision points       3    class polygon {
                                  4
                                  5    public function perimeter()
                                  6    {
#phpday           CCN         1   7        if (!is_array($this->vertices)) {
                                  8            return false;
                                  9        }
                                  10
                                  11        $perimeter = 0;
                                  12
                                  13        foreach ($this->vertices as $vertex) {
                                  14          $perimenter += $vertex;
                                  15        }
                                  16
                                  17        return $perimeter;
                                  18        }
                                  19   }
                                  20   ?>
Ciclomatic Complexity
                                  1    <?php
                                  2
          # decision points       3    class polygon {
                                  4
                                  5    public function perimeter()
                                  6    {
#phpday           CCN         2   7        if (!is_array($this->vertices)) {
                                  8            return false;
                                  9        }
                                  10
                                  11        $perimeter = 0;
                                  12
                                  13        foreach ($this->vertices as $vertex) {
                                  14          $perimenter += $vertex;
                                  15        }
                                  16
                                  17        return $perimeter;
                                  18        }
                                  19   }
                                  20   ?>
Ciclomatic Complexity
                                  1    <?php
                                  2
          # decision points       3    class polygon {
                                  4
                                  5    public function perimeter()
                                  6    {
#phpday           CCN         3   7        if (!is_array($this->vertices)) {
                                  8            return false;
                                  9        }
                                  10
                                  11        $perimeter = 0;
                                  12
                                  13        foreach ($this->vertices as $vertex) {
                                  14          $perimenter += $vertex;
                                  15        }
                                  16
                                  17        return $perimeter;
                                  18        }
                                  19   }
                                  20   ?>
Ciclomatic Complexity
                                  1    <?php
                                  2
          # decision points       3    class polygon {
                                  4
                                  5    public function perimeter()
                                  6    {
#phpday           CCN         4   7        if (!is_array($this->vertices)) {
                                  8            return false;
                                  9        }
                                  10
                                  11        $perimeter = 0;
                                  12
                                  13        foreach ($this->vertices as $vertex) {
                                  14          $perimenter += $vertex;
                                  15        }
                                  16
                                  17        return $perimeter;
                                  18        }
                                  19   }
                                  20   ?>
CCN Range Values


#phpday         1 - 4: low
               5-7: medium
                8-10: high
                11+: wtf
NPath Complexity
                            1    <?php
                            2
          # acyclic paths   3    class polygon {
                            4
                            5    public function perimeter()
                            6    {
#phpday           NPath     7        if (!is_array($this->vertices)) {
                            8            return false;
                            9        }
                            10
                            11        $perimeter = 0;
                            12
                            13        foreach ($this->vertices as $vertex) {
                            14          $perimenter += $vertex;
                            15        }
                            16
                            17        return $perimeter;
                            18        }
                            19   }
                            20   ?>
NPath Complexity
                                1    <?php
                                2
          # acyclic paths       3    class polygon {
                                4
                                5    public function perimeter()
                                6    {
#phpday           NPath     1   7        if (!is_array($this->vertices)) {
                                8            return false;
                                9        }
                                10
                                11        $perimeter = 0;
                                12
                                13        foreach ($this->vertices as $vertex) {
                                14          $perimenter += $vertex;
                                15        }
                                16
                                17        return $perimeter;
                                18        }
                                19   }
                                20   ?>
NPath Complexity
                                1    <?php
                                2
          # acyclic paths       3    class polygon {
                                4
                                5    public function perimeter()
                                6    {
#phpday           NPath     2   7        if (!is_array($this->vertices)) {
                                8            return false;
                                9        }
                                10
                                11        $perimeter = 0;
                                12
                                13        foreach ($this->vertices as $vertex) {
                                14          $perimenter += $vertex;
                                15        }
                                16
                                17        return $perimeter;
                                18        }
                                19   }
                                20   ?>
NPath Complexity
                                1    <?php
                                2
          # acyclic paths       3    class polygon {
                                4
                                5    public function perimeter()
                                6    {
#phpday           NPath     3   7        if (!is_array($this->vertices)) {
                                8            return false;
                                9        }
                                10
                                11        $perimeter = 0;
                                12
                                13        foreach ($this->vertices as $vertex) {
                                14          $perimenter += $vertex;
                                15        }
                                16
                                17        return $perimeter;
                                18        }
                                19   }
                                20   ?>
NPath Complexity
                                1    <?php
                                2
          # acyclic paths       3    class polygon {
                                4
                                5    public function perimeter()
                                6    {
#phpday           NPath     4   7        if (!is_array($this->vertices)) {
                                8            return false;
                                9        }
                                10
                                11        $perimeter = 0;
                                12
                                13        foreach ($this->vertices as $vertex) {
                                14          $perimenter += $vertex;
                                15        }
                                16
                                17        return $perimeter;
                                18        }
                                19   }
                                20   ?>
NPath Treshold


#phpday




             Critical if > 200
#phpday
          PHP Depend
           http://pdepend.org
#phpday
Overview Pyramid


#phpday
#phpday


          OO Metrics
Afferent/Efferent Coupling


#phpday



          Ca: no. of unique incoming dependencies
          Ce: no. of unique outgoing dependencies
Afferent/Efferent Coupling

                         Shape
                         area()
#phpday



               Circle             Triangle
                area()              area()




              Math
               PI
Afferent/Efferent Coupling

                            Shape
                             area()
#phpday



               Circle                 Triangle
                area()                  area()




              Math       Ca: 1
               PI        Ce: 0
Afferent/Efferent Coupling

                               Shape
                                area()
#phpday



          Ca: 0   Circle                 Triangle
          Ce: 2    area()                  area()




                  Math      Ca: 1
                   PI       Ce: 0
Afferent/Efferent Coupling

                               Shape     Ca: 2
                                area()   Ce: 0
#phpday



          Ca: 1   Circle                  Triangle
          Ce: 1    area()                   area()




                  Math      Ca: 1
                   PI       Ce: 0
Afferent/Efferent Coupling

                               Shape     Ca: 2
                                area()   Ce: 0
#phpday



          Ca: 1   Circle                  Triangle Ca: 0
          Ce: 1    area()                   area() Ce: 1



                  Math      Ca: 1
                   PI       Ce: 0
#phpday

          $ pdepend --jdepend-chart=j.png .
Instability Chart


#phpday




          A = AC / (CC + AC)
                               D = | A + I | -1
          I = Ce / (Ce + Ca)
#phpday
          PHP MD
          http://phpmd.org
PHP MD


#phpday    Code Size Rules
            Design Rules
            Naming Rules
          Unused Code Rules
#phpday             $ phpmd src/ xml
          codesize,design,naming,unusedcode --
                   reportfile pmd.xml
#phpday
#phpday


          Non Static Analysis
C.R.A.P


           Change Risk Analysis Predictions or
#phpday

                  “Your code is crap”


          CRAP = CCN^2 * (1 – COV/100)^3 + CCN
#phpday


          Putting it all together
#phpday
             PHP_CodeBrowser
          https://github.com/mayflowergmbh/PHP_CodeBrowser.git
$ phpcb --log logs --source src --output
#phpday



                      code-browser
#phpday
             PHP Project Wizard
          https://github.com/sebastianbergmann/php-project-wizard.git
Code Metrics as a mean to expose
#phpday



                  internal quality
Further Reading


          http://manuel-pichler.de/
#phpday

          http://pdepend.org
          http://phpmd.org
          http://www.artima.com/weblogs/viewpost.jsp?thread=215899
Questions?

              @_orso_
#phpday
            mo@ideato.it


          http://joind.in/2989

Mais conteúdo relacionado

Mais procurados

Pmr trial-2010-math-qa-perak
Pmr trial-2010-math-qa-perakPmr trial-2010-math-qa-perak
Pmr trial-2010-math-qa-perakpheobi PHEOBI
 
FP305 data structure june 2012
FP305   data structure june 2012FP305   data structure june 2012
FP305 data structure june 2012Syahriha Ruslan
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGAmira Dolce Farhana
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.organnaunivedu
 

Mais procurados (6)

005 ellipse
005 ellipse005 ellipse
005 ellipse
 
Pmr trial-2010-math-qa-perak
Pmr trial-2010-math-qa-perakPmr trial-2010-math-qa-perak
Pmr trial-2010-math-qa-perak
 
FP305 data structure june 2012
FP305   data structure june 2012FP305   data structure june 2012
FP305 data structure june 2012
 
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMINGFINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
FINAL PAPER FP301 OBJECT ORIENTED PROGRAMMING
 
Gate-Cs 1995
Gate-Cs 1995Gate-Cs 1995
Gate-Cs 1995
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
 

Destaque

Solor system pp
Solor system ppSolor system pp
Solor system ppballe1km
 
Kebijakan moneter
Kebijakan moneterKebijakan moneter
Kebijakan moneterTedy El
 
Solar system
Solar system Solar system
Solar system balle1km
 
Continuous, continuous, continuous
Continuous, continuous, continuousContinuous, continuous, continuous
Continuous, continuous, continuousMichele Orselli
 
Let's take over the world with Zend Framework
Let's take over the world with Zend FrameworkLet's take over the world with Zend Framework
Let's take over the world with Zend FrameworkMartin de Keijzer
 
Solor system pp
Solor system ppSolor system pp
Solor system ppballe1km
 
Final Solor system pp
Final Solor system ppFinal Solor system pp
Final Solor system ppballe1km
 
Let’s count money
Let’s count moneyLet’s count money
Let’s count moneyschra2ja
 
Productive & easy mobile app dev
Productive & easy mobile app devProductive & easy mobile app dev
Productive & easy mobile app devMartin de Keijzer
 
High quality live broadcasting with PHP 27 07-2016
High quality live broadcasting with PHP 27 07-2016High quality live broadcasting with PHP 27 07-2016
High quality live broadcasting with PHP 27 07-2016Martin de Keijzer
 

Destaque (13)

Solor system pp
Solor system ppSolor system pp
Solor system pp
 
Kebijakan moneter
Kebijakan moneterKebijakan moneter
Kebijakan moneter
 
Solar system
Solar system Solar system
Solar system
 
Continuous, continuous, continuous
Continuous, continuous, continuousContinuous, continuous, continuous
Continuous, continuous, continuous
 
DPC Tutorial
DPC TutorialDPC Tutorial
DPC Tutorial
 
Let's take over the world with Zend Framework
Let's take over the world with Zend FrameworkLet's take over the world with Zend Framework
Let's take over the world with Zend Framework
 
AChE
AChEAChE
AChE
 
Solor system pp
Solor system ppSolor system pp
Solor system pp
 
Final Solor system pp
Final Solor system ppFinal Solor system pp
Final Solor system pp
 
Let’s count money
Let’s count moneyLet’s count money
Let’s count money
 
Productive & easy mobile app dev
Productive & easy mobile app devProductive & easy mobile app dev
Productive & easy mobile app dev
 
High quality live broadcasting with PHP 27 07-2016
High quality live broadcasting with PHP 27 07-2016High quality live broadcasting with PHP 27 07-2016
High quality live broadcasting with PHP 27 07-2016
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Semelhante a Dica trentatrè. &lt;?php echo "33"; ?>. Controllare lo stato di salute di una applicazione con le metriche del codice

Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your codevmandrychenko
 
Part 3-functions
Part 3-functionsPart 3-functions
Part 3-functionsankita44
 
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdf
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdfbreaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdf
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdfVishalKumarJha10
 
User defined functions
User defined functionsUser defined functions
User defined functionsshubham_jangid
 
Csphtp1 10
Csphtp1 10Csphtp1 10
Csphtp1 10HUST
 
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo FinochiettiRoslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti.NET Conf UY
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
Example for Abstract Class and Interface.pdf
Example for Abstract Class and Interface.pdfExample for Abstract Class and Interface.pdf
Example for Abstract Class and Interface.pdfrajaratna4
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoAchim Friedland
 
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docxCSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docxfaithxdunce63732
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++NUST Stuff
 

Semelhante a Dica trentatrè. &lt;?php echo "33"; ?>. Controllare lo stato di salute di una applicazione con le metriche del codice (20)

Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your code
 
Functions12
Functions12Functions12
Functions12
 
Functions123
Functions123 Functions123
Functions123
 
Part 3-functions
Part 3-functionsPart 3-functions
Part 3-functions
 
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdf
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdfbreaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdf
breaking_dependencies_the_solid_principles__klaus_iglberger__cppcon_2020.pdf
 
User defined functions
User defined functionsUser defined functions
User defined functions
 
Csphtp1 10
Csphtp1 10Csphtp1 10
Csphtp1 10
 
3433 Ch10 Ppt
3433 Ch10 Ppt3433 Ch10 Ppt
3433 Ch10 Ppt
 
cpp_sample
cpp_samplecpp_sample
cpp_sample
 
Chapter 17 corba
Chapter 17 corbaChapter 17 corba
Chapter 17 corba
 
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo FinochiettiRoslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
 
Roslyn: el futuro de C#
Roslyn: el futuro de C#Roslyn: el futuro de C#
Roslyn: el futuro de C#
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
Example for Abstract Class and Interface.pdf
Example for Abstract Class and Interface.pdfExample for Abstract Class and Interface.pdf
Example for Abstract Class and Interface.pdf
 
C++ classes
C++ classesC++ classes
C++ classes
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
 
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docxCSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
CSC139 Chapter 10 Lab Assignment (2)PolymorphismObjectivesIn.docx
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++
 

Mais de Michele Orselli

Tackling Tech Debt with Rector
Tackling Tech Debt with RectorTackling Tech Debt with Rector
Tackling Tech Debt with RectorMichele Orselli
 
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...Michele Orselli
 
A recommendation engine for your applications codemotion ams
A recommendation engine for your applications codemotion amsA recommendation engine for your applications codemotion ams
A recommendation engine for your applications codemotion amsMichele Orselli
 
A recommendation engine for your applications phpday
A recommendation engine for your applications phpdayA recommendation engine for your applications phpday
A recommendation engine for your applications phpdayMichele Orselli
 
Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Michele Orselli
 
A recommendation engine for your php application
A recommendation engine for your php applicationA recommendation engine for your php application
A recommendation engine for your php applicationMichele Orselli
 
Symfony e micro (non così tanto) services
Symfony e micro (non così tanto) servicesSymfony e micro (non così tanto) services
Symfony e micro (non così tanto) servicesMichele Orselli
 
Hopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherHopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherMichele Orselli
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Michele Orselli
 
Implementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfImplementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfMichele Orselli
 
Server side data sync for mobile apps with silex
Server side data sync for mobile apps with silexServer side data sync for mobile apps with silex
Server side data sync for mobile apps with silexMichele Orselli
 
Deploy a PHP App on Google App Engine
Deploy a PHP App on Google App EngineDeploy a PHP App on Google App Engine
Deploy a PHP App on Google App EngineMichele Orselli
 
Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsMichele Orselli
 
Deploy a php app on Google App Engine
Deploy a php app on Google App EngineDeploy a php app on Google App Engine
Deploy a php app on Google App EngineMichele Orselli
 
Manage a project portfolio
Manage a project portfolioManage a project portfolio
Manage a project portfolioMichele Orselli
 

Mais de Michele Orselli (20)

Tackling Tech Debt with Rector
Tackling Tech Debt with RectorTackling Tech Debt with Rector
Tackling Tech Debt with Rector
 
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
Comunicare, condividere e mantenere decisioni architetturali nei team di svil...
 
A dive into Symfony 4
A dive into Symfony 4A dive into Symfony 4
A dive into Symfony 4
 
A recommendation engine for your applications codemotion ams
A recommendation engine for your applications codemotion amsA recommendation engine for your applications codemotion ams
A recommendation engine for your applications codemotion ams
 
A recommendation engine for your applications phpday
A recommendation engine for your applications phpdayA recommendation engine for your applications phpday
A recommendation engine for your applications phpday
 
Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17
 
A recommendation engine for your php application
A recommendation engine for your php applicationA recommendation engine for your php application
A recommendation engine for your php application
 
Symfony e micro (non così tanto) services
Symfony e micro (non così tanto) servicesSymfony e micro (non così tanto) services
Symfony e micro (non così tanto) services
 
Hopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherHopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to another
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
Migrare a Symfony 3
Migrare a Symfony 3Migrare a Symfony 3
Migrare a Symfony 3
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
Implementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfImplementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconf
 
Server side data sync for mobile apps with silex
Server side data sync for mobile apps with silexServer side data sync for mobile apps with silex
Server side data sync for mobile apps with silex
 
Deploy a PHP App on Google App Engine
Deploy a PHP App on Google App EngineDeploy a PHP App on Google App Engine
Deploy a PHP App on Google App Engine
 
Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile Apps
 
Deploy a php app on Google App Engine
Deploy a php app on Google App EngineDeploy a php app on Google App Engine
Deploy a php app on Google App Engine
 
Sf2 wtf
Sf2 wtfSf2 wtf
Sf2 wtf
 
Manage a project portfolio
Manage a project portfolioManage a project portfolio
Manage a project portfolio
 

Último

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
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
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 

Último (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Dica trentatrè. &lt;?php echo "33"; ?>. Controllare lo stato di salute di una applicazione con le metriche del codice

  • 1. #phpday Dica trentatrè <?php echo ’33’ ?> Controllare lo stato di salute di una applicazione con le metriche del codice Michele Orselli (@_orso_)
  • 2. #phpday Code Metrics
  • 3. Measure of some property of a piece #phpday of software (Wikipedia)
  • 4. #phpday Who Cares?
  • 5. #phpday How long will it take to add feature X?
  • 6. #phpday Internal vs External Quality
  • 7. Code Metrics as a mean to expose #phpday internal quality
  • 8. #phpday How long will it take to add feature X?
  • 9. #phpday Classic
  • 10. Lines and Numbers Lines LOC: Lines Of Code #phpday ELOC: Executable LOC CLOC: Comment LOC NCLOC: Non-Comment LOC Numbers NOC: Number Of Classes NOM: Number Of Methods NOP: Number Of Packages
  • 11. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday 7 abstract function area(); 8 } 9 10 class circle extends shape { 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 12. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday 7 abstract function area(); 8 } 9 10 class circle extends shape { 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 13. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } 9 10 class circle extends shape { 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 14. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } NCLOC 20 9 10 class circle extends shape { 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 15. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } NCLOC 20 9 10 class circle extends shape { ELOC 3 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 16. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } NCLOC 20 9 10 class circle extends shape { ELOC 3 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } NOP 1 16 17 class triangle extends shape { 18 19 public function area() {} 20 } 21 22 ?>
  • 17. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } NCLOC 20 9 10 class circle extends shape { ELOC 3 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } NOP 1 16 17 class triangle extends shape { NOC 3 18 19 public function area() {} 20 } 21 22 ?>
  • 18. Lines and Numbers 1 <?php 2 Lines 3 namespace shapestwodimensional; 4 LOC 22 5 abstract class shape { 6 /* Returns the area of the shape */ #phpday CLOC 2 7 abstract function area(); 8 } NCLOC 20 9 10 class circle extends shape { ELOC 3 11 public function area() {} 12 13 /* Ret the diameter of the circle */ Numbers 14 public function diameter() {} 15 } NOP 1 16 17 class triangle extends shape { NOC 3 18 19 public function area() {} NOM 4 20 } 21 22 ?>
  • 19. #phpday phploc http://sebastianbergmann.github.com/phploc/
  • 21. #phpday Complexity
  • 22. Complexity #phpday Control Structures Complexity if, elseif, for, while, foreach, catch, case, xor, and, or, &&, ||, ?: Ciclomatic Complexity (CCN) NPath Complexity
  • 23. Ciclomatic Complexity 1 <?php 2 # decision points 3 class polygon { 4 5 public function perimeter() 6 { #phpday CCN 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 24. Ciclomatic Complexity 1 <?php 2 # decision points 3 class polygon { 4 5 public function perimeter() 6 { #phpday CCN 1 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 25. Ciclomatic Complexity 1 <?php 2 # decision points 3 class polygon { 4 5 public function perimeter() 6 { #phpday CCN 2 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 26. Ciclomatic Complexity 1 <?php 2 # decision points 3 class polygon { 4 5 public function perimeter() 6 { #phpday CCN 3 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 27. Ciclomatic Complexity 1 <?php 2 # decision points 3 class polygon { 4 5 public function perimeter() 6 { #phpday CCN 4 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 28. CCN Range Values #phpday 1 - 4: low 5-7: medium 8-10: high 11+: wtf
  • 29. NPath Complexity 1 <?php 2 # acyclic paths 3 class polygon { 4 5 public function perimeter() 6 { #phpday NPath 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 30. NPath Complexity 1 <?php 2 # acyclic paths 3 class polygon { 4 5 public function perimeter() 6 { #phpday NPath 1 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 31. NPath Complexity 1 <?php 2 # acyclic paths 3 class polygon { 4 5 public function perimeter() 6 { #phpday NPath 2 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 32. NPath Complexity 1 <?php 2 # acyclic paths 3 class polygon { 4 5 public function perimeter() 6 { #phpday NPath 3 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 33. NPath Complexity 1 <?php 2 # acyclic paths 3 class polygon { 4 5 public function perimeter() 6 { #phpday NPath 4 7 if (!is_array($this->vertices)) { 8 return false; 9 } 10 11 $perimeter = 0; 12 13 foreach ($this->vertices as $vertex) { 14 $perimenter += $vertex; 15 } 16 17 return $perimeter; 18 } 19 } 20 ?>
  • 34. NPath Treshold #phpday Critical if > 200
  • 35. #phpday PHP Depend http://pdepend.org
  • 38. #phpday OO Metrics
  • 39. Afferent/Efferent Coupling #phpday Ca: no. of unique incoming dependencies Ce: no. of unique outgoing dependencies
  • 40. Afferent/Efferent Coupling Shape area() #phpday Circle Triangle area() area() Math PI
  • 41. Afferent/Efferent Coupling Shape area() #phpday Circle Triangle area() area() Math Ca: 1 PI Ce: 0
  • 42. Afferent/Efferent Coupling Shape area() #phpday Ca: 0 Circle Triangle Ce: 2 area() area() Math Ca: 1 PI Ce: 0
  • 43. Afferent/Efferent Coupling Shape Ca: 2 area() Ce: 0 #phpday Ca: 1 Circle Triangle Ce: 1 area() area() Math Ca: 1 PI Ce: 0
  • 44. Afferent/Efferent Coupling Shape Ca: 2 area() Ce: 0 #phpday Ca: 1 Circle Triangle Ca: 0 Ce: 1 area() area() Ce: 1 Math Ca: 1 PI Ce: 0
  • 45. #phpday $ pdepend --jdepend-chart=j.png .
  • 46. Instability Chart #phpday A = AC / (CC + AC) D = | A + I | -1 I = Ce / (Ce + Ca)
  • 47. #phpday PHP MD http://phpmd.org
  • 48. PHP MD #phpday Code Size Rules Design Rules Naming Rules Unused Code Rules
  • 49. #phpday $ phpmd src/ xml codesize,design,naming,unusedcode -- reportfile pmd.xml
  • 51. #phpday Non Static Analysis
  • 52. C.R.A.P Change Risk Analysis Predictions or #phpday “Your code is crap” CRAP = CCN^2 * (1 – COV/100)^3 + CCN
  • 53. #phpday Putting it all together
  • 54. #phpday PHP_CodeBrowser https://github.com/mayflowergmbh/PHP_CodeBrowser.git
  • 55. $ phpcb --log logs --source src --output #phpday code-browser
  • 56. #phpday PHP Project Wizard https://github.com/sebastianbergmann/php-project-wizard.git
  • 57. Code Metrics as a mean to expose #phpday internal quality
  • 58. Further Reading http://manuel-pichler.de/ #phpday http://pdepend.org http://phpmd.org http://www.artima.com/weblogs/viewpost.jsp?thread=215899
  • 59. Questions? @_orso_ #phpday mo@ideato.it http://joind.in/2989

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n