SlideShare ist ein Scribd-Unternehmen logo
1 von 84
Downloaden Sie, um offline zu lesen
Metrics and Problem Detection



Jorge Ressia
Software is complex.



   29% Succeeded

      18% Failed



   53% Challenged



 The Standish Group, 2004
How large is your project?


    1’000’000 lines of code
    * 2 = 2’000’000 seconds
      / 3600 = 560 hours
         / 8 = 70 days
       / 20 = 3 months
}
                                                 }
                                             {
                                             {



                                                 }
                                                 }
                                             {
                                             {




                                         g
                                   rin
                              ee
                        gin
                   en
               d
          ar
     rw
fo
fo
                                             rw
                                              ar
                                                d
                                                  en
                                                     gin
                                                      ee
                                                       rin
                                                           g
{               {
    {                   {                                      {               {
                            }                                      {               {
        }
        }                       actual development                     }               }
            }       {       }                                              }               }
What is the current state?




                                           fo
                                             rw
                                              ar
What should we do?




                                                d
                                                  en
Where to start?




                                                     gin
                                                      ee
How to proceed?




                                                       rin
                                                           g
{               {
    {                   {                                      {               {
                            }                                      {               {
        }
        }                       actual development                     }               }
            }       {       }                                              }               }
fo
                                                                rw
                                               g
                                           rin




                                                                 ar
                                          ee




                                                                   d
                                         gin




                                                                     en
                                                                        gin
                                     en




                                                                         ee
                                     e
                                 rs




                                                                          rin
                                ve




                                                                              g
                                re




{               {
    {                   {                                                         {               {
                            }                                                         {               {
        }
        }                                          actual development                     }               }
            }       {       }                                                                 }               }
Reverse engineering is analyzing a subject system to:
 identify components and their relationships, and
 create more abstract representations.




                                 Chikofky & Cross, 90
quality?
        udg e its
    to j
How                  {
                         {
                                     {
                                             {
                                                 }
                             }
                             }
                                 }       {       }




    A large system contains lots of details.
http://moose.unibe.ch




http://loose.upt.ro/incode
1
Metrics
                             2Design
                             Problems




              3
          Code Duplication
Metrics




          1
Youcannot control
what you cannot measure.




                           Tom de Marco
Metrics are functions that assign numbers to
products, processes and resources.
Software metrics are measurements which
relate to software systems, processes or
related documents.
Metrics compress system traits into numbers.
Let’s see some examples...
Examples of size metrics


NOM - number of methods
NOA - number of attributes
LOC - number of lines of code
NOS - number of statements
NOC - number of children



                                      Lorenz, Kidd, 1994
                                Chidamber, Kemerer, 1994
McCabe cyclomatic complexity (CYCLO) counts
the number of independent paths through the code of a
function.

                                                         McCabe, 1977




  it reveals the minimum number of tests to write

  interpretation can’t directly lead to improvement action
Weighted Method Count (WMC) sums up the
complexity of class’ methods (measured by the metric
of your choice; usually CYCLO).

                                             Chidamber, Kemerer, 1994




  it is configurable, thus adaptable to our precise needs

  interpretation can’t directly lead to improvement action
Depth of Inheritance Tree (DIT) is the (maximum)
depth level of a class in a class hierarchy.


                                             Chidamber, Kemerer, 1994




  inheritance is measured

  only the potential and not the real impact is quantified
Coupling between objects (CBO) shows the number
of classes from which methods or attributes are used.


                                              Chidamber, Kemerer, 1994




  it takes into account real dependencies not just declared ones

  no differentiation of types and/or intensity of coupling
Tight Class Cohesion (TCC) counts the relative
number of method-pairs that access attributes of the
class in common.

                                                   Bieman, Kang, 1995


         TCC = 2 / 10 = 0.2




  interpretation can lead to improvement action

  ratio values allow comparison between systems
Access To Foreign Data (ATFD) counts how many
attributes from other classes are accessed directly from
a measured class.

                                           Marinescu 2006
...
Design Problems




                  2
McCall, 1977
Metrics Assess and Improve Quality!




                  ea lly?
              R
McCall, 1977
Problem 1: metrics granularity




                                           ?
capture symptoms, not causes of problems

in isolation,
they don’t lead to improvement solutions




Problem 2: implicit mapping
we don’t reason in terms of metrics,
but in terms of design principles
2   big obstacles in using metrics:


     Thresholds make metrics hard to interpret

     Granularity make metrics hard to use in isolation
Can metrics help me
             in what I really care for? :)
et rics!
                                                ith m
                                        o   do w
                                thi ng t
                    an t no
            Iw




                                                                fo
                                                                rw
                                                                 ar
How do I understand code?




                                                                     d
                                                                     en
How do I improve code?




                                                                         gin
                                                                          ee
                                                                           rin
                                                                               g
{               {
    {                   {                                                          {               {
                            }                                                          {               {
        }
        }                                      actual development                          }               }
            }       {       }                                                                  }               }
How to get an initial   understanding of a system?
Metric   Value
LOC      35175
NOM       3618
NOC        384
CYCLO     5579
NOP         19
CALLS    15128
FANOUT    8590
AHH        0.12
ANDC       0.31
Metric                  Value
LOC                      35175
NOM                       3618
NOC                        384
CYCLO                     5579
NOP                         19
CALLS                    15128
FANOUT                    8590
                         t?
                      wha
AHH
             nd now       0.12
         A
ANDC                      0.31
We need means to compare.
hierarchies?

               coupling?
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006


                                  Inheritance
                                 ANDC      0.31
                                 AHH       0.12
                         20.21   NOP         19
               9.42      NOC                384
        9.72   NOM                         3618    NOM        418
0.15    LOC                               35175 15128       CALLS      0.56
CYCLO                                      5579 8590                FANOUT

                      Size                              Communication
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006




                                 ANDC    0.31
                                 AHH     0.12
                         20.21   NOP       19
               9.42      NOC              384
        9.72   NOM                       3618    NOM     418
0.15    LOC                             35175 15128    CALLS      0.56
CYCLO                                    5579 8590             FANOUT

                      Size
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006




                              ANDC    0.31
                              AHH     0.12
                      20.21   NOP       19
               9.42   NOC              384
        9.72   NOM                    3618    NOM        418
0.15    LOC                          35175 15128       CALLS      0.56
CYCLO                                 5579 8590                FANOUT

                                                   Communication
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006


                               Inheritance
                              ANDC      0.31
                              AHH       0.12
                      20.21   NOP         19
               9.42   NOC                384
        9.72   NOM                      3618    NOM     418
0.15    LOC                            35175 15128    CALLS      0.56
CYCLO                                   5579 8590             FANOUT
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006




                              ANDC    0.31
                              AHH     0.12
                      20.21   NOP       19
               9.42   NOC              384
        9.72   NOM                    3618    NOM     418
0.15    LOC                          35175 15128    CALLS      0.56
CYCLO                                 5579 8590             FANOUT
Java                 C++
            LOW    AVG    HIGH   LOW    AVG    HIGH

CYCLO/LOC   0.16   0.20   0.24   0.20   0.25   0.30

LOC/NOM      7      10     13     5     10      16

NOM/NOC      4      7      10     4      9      15

   ...
The Overview Pyramid provides a metrics
  overview.                         Lanza, Marinescu 2006




                                 ANDC           0.31
                                 AHH            0.12
                         20.21   NOP              19
                  9.42   NOC                     384
          9.72    NOM                           3618    NOM       418
0.15      LOC                               35175 15128         CALLS      0.56
CYCLO                                           5579 8590               FANOUT




       close to high         close to average               close to low
The Overview Pyramid provides a metrics
overview.                         Lanza, Marinescu 2006




 close to high     close to average     close to low
rics!
                                                      met
                                            do with
                                        o
                                    ng t
                   n            othi
            Iw ant




                                                                 fo
                                                                 rw
                                                                  ar
How do I understand code?




                                                                      d
                                                                      en
How do I improve code?




                                                                          gin
                                                                           ee
                                                                            rin
                                                                                g
{               {
    {                   {                                                           {               {
                            }                                                           {               {
        }
        }                                       actual development                          }               }
            }       {       }                                                                   }               }
How do I improve code?
Quality is more than 0 bugs.



Breaking design principles, rules and best practices
          deteriorates the code;
          it leads to design problems.
Imagine changing just a small design fragment




and33%
of all classes
would require changes
expensive
Design problems
are frequent
                    unavoidable


                                                          ?
                                                    e them
                                               inat
                                           elim
                                     and
                              detect
                     How to
God Classes tend to centralize the intelligence of the
system, to do everything and to use data from small
data-classes.
                                                Riel, 1996
God Classes tend
    to centralize the intelligence of the system,
    to do everything and
    to use data from small data-classes.
God Classes
    centralize the intelligence of the system,
    do everything and
    use data from small data-classes.
God Classes
    are complex,
    are not cohesive,
    access external data.
God Classes
    are complex,
     
    WMC is high
    are not cohesive,

    TCC is low
    access external data.
 ATFD more than few


                                               su sing
                                         u erie
                                     to q s
                                cs in rator
                            etri pe
                        se m ical o
                 C o mpo log
Detection Strategies are metric-based queries to
detect design flaws.                  Lanza, Marinescu 2006




                  Rule 1


          METRIC 1 > Threshold 1

                                   AND   Quality problem

                  Rule 2


          METRIC 2 < Threshold 2
A God Class centralizes too much intelligence in
the system.                         Lanza, Marinescu 2006


       Class uses directly more than a
       few attributes of other classes

               ATFD > FEW




        Functional complexity of the
             class is very high
                                         AND   GodClass
            WMC ! VERY HIGH




           Class cohesion is low


            TCC < ONE THIRD
An Envious Method is more interested in data
from a handful of classes.         Lanza, Marinescu 2006


      Method uses directly more than
      a few attributes of other classes

               ATFD > FEW




      Method uses far more attributes
       of other classes than its own
                                          AND   Feature Envy
            LAA < ONE THIRD




        The used quot;foreignquot; attributes
      belong to very few other classes

                FDP ! FEW
Data Classes are dumb data holders.
                                                  Lanza, Marinescu 2006




        Interface of class reveals data
         rather than offering services

            WOC < ONE THIRD
                                            AND    Data Class


     Class reveals many attributes and is
                not complex
Data Classes are dumb data holders.
                                             Lanza, Marinescu 2006

     More than a few public
             data

     NOAP + NOAM > FEW
                                 AND
    Complexity of class is not
              high

          WMC < HIGH
                                            Class reveals many
                                       OR   attributes and is not
     Class has many public                         complex
             data

    NOAP + NOAM > MANY
                                 AND
    Complexity of class is not
          very high

      WMC < VERY HIGH
Shotgun Surgery depicts that a change in an
operation triggers many (small) in a lot of different
operation and classes.
                                      Lanza, Marinescu 2006
Code Duplication




                   3
What is Code Duplication?

                                            so f it?
                                 pro blem
                            he
                    ta re t
                 a
               Wh
Code Duplication Detection




     Lexical Equivalence

     Syntactical Equivalence

     Semantic Equivalence
Visualization of Copied Code Sequences

                File A      File B




      File A




      File B
Transformation                   Comparison




           Source Code            Transformed Code              Duplication Data




Author            Level         Transformed Code              Comparison Technique

Johnson 94        Lexical       Substrings                    String-Matching

Ducasse 99        Lexical       Normalized Strings            String-Matching

Baker 95          Syntactical   Parameterized Strings         String-Matching

Mayrand 96        Syntactical   Metrics Tuples                Discrete comparison

Kontogiannis 97   Syntactical   Metrics Tuples                Euclidean distance

Baxter 98         Syntactical   AST                           Tree-Matching
Noise Elimination




…
//assign same fastid as container    fastid=NULL;
fastid = NULL;                       constchar*fidptr=get_fastid();
const char* fidptr = get_fastid();   if(fidptr!=NULL)
if(fidptr != NULL) {                 intl=strlen(fidptr)
  int l = strlen(fidptr);            fastid = newchar[l+]
  fastid = newchar[ l + 1 ];
Enhanced Simple Detection Approach
lines from source
         a   b   c   d    a    b     c   d




 lines
 from
source
lines from source
         a   b   c   d    a    x     y   d




 lines
 from
source
lines from source
         a   b   c   a    b    x     y   c




 lines
 from
source
lines from source
         a   x   b    x   c    x     d   x




 lines
 from
source
lines from source 2




  lines
  from
source 1
lines from source 2




  lines
  from
source 1
lines from source 2




  lines
  from
source 1




           exact
           chunk
lines from source 2




  lines
  from
source 1




           exact      line
           chunk      bias
lines from source 2




  lines
  from
source 1




           exact      line       exact
           chunk      bias       chunk
Significant Duplication:
- It is the largest possible duplication chain uniting
all exact clones that are close enough to each
other.
- The duplication is large enough.
                                        Lanza, Marinescu 2006
1
Metrics
                             2Design
                             Problems




              3
          Code Duplication
Shotgun
                                Surgery                        has

     uses                  is

                           has (partial) Feature                     Data
                                          Envy         uses          Class

                                             is partially
                      God        has
Intensive             Class
Coupling                                   Brain        has
               has
                                          Method
Extensive             Brain         has                       Significant
Coupling              Class                                   Duplication
               has
                           is
                 is
                                                 has
     Refused
                     is   Tradition
      Parent
                          Breaker
     Bequest
                                has (subclass)


                            Futile
                          Hierarchy                                  Lanza, Marinescu 2006

   Identity               Collaboration            Classification
Disharmonies              Disharmonies             Disharmonies
Follow a clear and repeatable process



                                                  mb ers!
                                                 u
                                          ms of n
                                 in ter
                      qu ality
                 ut
           n abo
       easo
Don’t r
QA is part of the the Development Process




         http://loose.upt.ro/incode
Tudor Gîrba
       www.tudorgirba.com


      Jorge Ressia




creativecommons.org/licenses/by/3.0/

Weitere ähnliche Inhalte

Andere mochten auch

Planificación TEOYE 1°APM 2014
Planificación TEOYE 1°APM 2014Planificación TEOYE 1°APM 2014
Planificación TEOYE 1°APM 2014silvias10
 
Historia del Planeta Alfa, "el manantial sagrado".
Historia del Planeta Alfa, "el manantial sagrado". Historia del Planeta Alfa, "el manantial sagrado".
Historia del Planeta Alfa, "el manantial sagrado". EDUCACIÓN TOLEDO
 
Insan ve bilgisayar etkileşimi / Human Computer interaction
Insan ve bilgisayar etkileşimi / Human Computer interactionInsan ve bilgisayar etkileşimi / Human Computer interaction
Insan ve bilgisayar etkileşimi / Human Computer interactionNejat Kutup
 
Dominguez n fichasdecontenido
Dominguez n fichasdecontenidoDominguez n fichasdecontenido
Dominguez n fichasdecontenidoNerea Dominguez
 
Cómo registrar tu marca en España paso a paso
Cómo registrar tu marca en España paso a pasoCómo registrar tu marca en España paso a paso
Cómo registrar tu marca en España paso a pasoeconred
 
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable Practi...
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable  Practi...ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable  Practi...
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable Practi...ISLE Network
 
Principles of site design
Principles of site designPrinciples of site design
Principles of site designKnoldus Inc.
 
Turismo Fluvial en Alemania - 2012
Turismo Fluvial en Alemania - 2012Turismo Fluvial en Alemania - 2012
Turismo Fluvial en Alemania - 2012Keltia Viatges
 
Sps Conferenc Essen 2009 Stenum Fresner
Sps Conferenc Essen 2009 Stenum FresnerSps Conferenc Essen 2009 Stenum Fresner
Sps Conferenc Essen 2009 Stenum FresnerCSCP
 
Inferring Versioned Schemas from NoSQL Databases and its Applications
Inferring Versioned Schemas from NoSQL Databases and its ApplicationsInferring Versioned Schemas from NoSQL Databases and its Applications
Inferring Versioned Schemas from NoSQL Databases and its ApplicationsDiego Sevilla Ruiz
 
Conceptos para avanzar juntos en la educación actual
Conceptos para avanzar juntos en la educación actualConceptos para avanzar juntos en la educación actual
Conceptos para avanzar juntos en la educación actualSelin Carrasco
 
Biografia web pilar
Biografia web pilarBiografia web pilar
Biografia web pilarpilarica11q
 
Wellness & Spa Hotel Lindenhof in South Tyrol
Wellness & Spa Hotel Lindenhof in South TyrolWellness & Spa Hotel Lindenhof in South Tyrol
Wellness & Spa Hotel Lindenhof in South TyrolLindenhof
 
MCCCD Experts
MCCCD ExpertsMCCCD Experts
MCCCD Expertsmcccd
 

Andere mochten auch (19)

Planificación TEOYE 1°APM 2014
Planificación TEOYE 1°APM 2014Planificación TEOYE 1°APM 2014
Planificación TEOYE 1°APM 2014
 
Historia del Planeta Alfa, "el manantial sagrado".
Historia del Planeta Alfa, "el manantial sagrado". Historia del Planeta Alfa, "el manantial sagrado".
Historia del Planeta Alfa, "el manantial sagrado".
 
Insan ve bilgisayar etkileşimi / Human Computer interaction
Insan ve bilgisayar etkileşimi / Human Computer interactionInsan ve bilgisayar etkileşimi / Human Computer interaction
Insan ve bilgisayar etkileşimi / Human Computer interaction
 
Dominguez n fichasdecontenido
Dominguez n fichasdecontenidoDominguez n fichasdecontenido
Dominguez n fichasdecontenido
 
Cómo registrar tu marca en España paso a paso
Cómo registrar tu marca en España paso a pasoCómo registrar tu marca en España paso a paso
Cómo registrar tu marca en España paso a paso
 
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable Practi...
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable  Practi...ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable  Practi...
ISLE Professionalization Fair 2. Soledad Gómez González: "Sustainable Practi...
 
June2016TradeComplianceOps
June2016TradeComplianceOpsJune2016TradeComplianceOps
June2016TradeComplianceOps
 
Principles of site design
Principles of site designPrinciples of site design
Principles of site design
 
Turismo Fluvial en Alemania - 2012
Turismo Fluvial en Alemania - 2012Turismo Fluvial en Alemania - 2012
Turismo Fluvial en Alemania - 2012
 
Handbook en
Handbook   enHandbook   en
Handbook en
 
Sps Conferenc Essen 2009 Stenum Fresner
Sps Conferenc Essen 2009 Stenum FresnerSps Conferenc Essen 2009 Stenum Fresner
Sps Conferenc Essen 2009 Stenum Fresner
 
Inferring Versioned Schemas from NoSQL Databases and its Applications
Inferring Versioned Schemas from NoSQL Databases and its ApplicationsInferring Versioned Schemas from NoSQL Databases and its Applications
Inferring Versioned Schemas from NoSQL Databases and its Applications
 
Conceptos para avanzar juntos en la educación actual
Conceptos para avanzar juntos en la educación actualConceptos para avanzar juntos en la educación actual
Conceptos para avanzar juntos en la educación actual
 
PresentacióN1
PresentacióN1PresentacióN1
PresentacióN1
 
Biografia web pilar
Biografia web pilarBiografia web pilar
Biografia web pilar
 
Ondas.pptx 11 b
Ondas.pptx 11 bOndas.pptx 11 b
Ondas.pptx 11 b
 
Wellness & Spa Hotel Lindenhof in South Tyrol
Wellness & Spa Hotel Lindenhof in South TyrolWellness & Spa Hotel Lindenhof in South Tyrol
Wellness & Spa Hotel Lindenhof in South Tyrol
 
MCCCD Experts
MCCCD ExpertsMCCCD Experts
MCCCD Experts
 
From Past to Present: Sustainable Transportation Practices in Graz
From Past to Present: Sustainable Transportation Practices in GrazFrom Past to Present: Sustainable Transportation Practices in Graz
From Past to Present: Sustainable Transportation Practices in Graz
 

Ähnlich wie 05 Problem Detection

Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)Tudor Girba
 
Modeling History to Understand Software Evolution with Hismo 2008-03-12
Modeling History to Understand Software Evolution with Hismo 2008-03-12Modeling History to Understand Software Evolution with Hismo 2008-03-12
Modeling History to Understand Software Evolution with Hismo 2008-03-12Tudor Girba
 
Modeling History to Understand Software Evolution With Hismo 2008-02-25
Modeling History to Understand Software Evolution With Hismo 2008-02-25 Modeling History to Understand Software Evolution With Hismo 2008-02-25
Modeling History to Understand Software Evolution With Hismo 2008-02-25 Tudor Girba
 
Reverse Engineering (EVO 2008)
Reverse Engineering (EVO 2008)Reverse Engineering (EVO 2008)
Reverse Engineering (EVO 2008)Tudor Girba
 
Assessing software systems
Assessing software systemsAssessing software systems
Assessing software systemsTudor Girba
 
Restructuring (EVO 2008)
Restructuring (EVO 2008)Restructuring (EVO 2008)
Restructuring (EVO 2008)Tudor Girba
 
Reverse Engineering 2007-11-27
Reverse Engineering 2007-11-27 Reverse Engineering 2007-11-27
Reverse Engineering 2007-11-27 Tudor Girba
 
Enhancing agile development through software assessment
Enhancing agile development through software assessmentEnhancing agile development through software assessment
Enhancing agile development through software assessmentTudor Girba
 
Humane assessment with Moose at Benevol 2010
Humane assessment with Moose at Benevol 2010Humane assessment with Moose at Benevol 2010
Humane assessment with Moose at Benevol 2010Tudor Girba
 
Helping you reengineering your legacy
Helping you reengineering your legacyHelping you reengineering your legacy
Helping you reengineering your legacyStéphane Ducasse
 
History Analysis (EVO 2008)
History Analysis (EVO 2008)History Analysis (EVO 2008)
History Analysis (EVO 2008)Tudor Girba
 
Reverse Engineering Techniques 2007-11-29
Reverse Engineering Techniques 2007-11-29 Reverse Engineering Techniques 2007-11-29
Reverse Engineering Techniques 2007-11-29 Tudor Girba
 
A Moose Slideshow
A Moose SlideshowA Moose Slideshow
A Moose SlideshowTudor Girba
 
The humane software assessment (Choose Forum 2009)
The humane software assessment (Choose Forum 2009)The humane software assessment (Choose Forum 2009)
The humane software assessment (Choose Forum 2009)Tudor Girba
 

Ähnlich wie 05 Problem Detection (15)

Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
 
Modeling History to Understand Software Evolution with Hismo 2008-03-12
Modeling History to Understand Software Evolution with Hismo 2008-03-12Modeling History to Understand Software Evolution with Hismo 2008-03-12
Modeling History to Understand Software Evolution with Hismo 2008-03-12
 
Modeling History to Understand Software Evolution With Hismo 2008-02-25
Modeling History to Understand Software Evolution With Hismo 2008-02-25 Modeling History to Understand Software Evolution With Hismo 2008-02-25
Modeling History to Understand Software Evolution With Hismo 2008-02-25
 
Reverse Engineering (EVO 2008)
Reverse Engineering (EVO 2008)Reverse Engineering (EVO 2008)
Reverse Engineering (EVO 2008)
 
Moose Overview
Moose OverviewMoose Overview
Moose Overview
 
Assessing software systems
Assessing software systemsAssessing software systems
Assessing software systems
 
Restructuring (EVO 2008)
Restructuring (EVO 2008)Restructuring (EVO 2008)
Restructuring (EVO 2008)
 
Reverse Engineering 2007-11-27
Reverse Engineering 2007-11-27 Reverse Engineering 2007-11-27
Reverse Engineering 2007-11-27
 
Enhancing agile development through software assessment
Enhancing agile development through software assessmentEnhancing agile development through software assessment
Enhancing agile development through software assessment
 
Humane assessment with Moose at Benevol 2010
Humane assessment with Moose at Benevol 2010Humane assessment with Moose at Benevol 2010
Humane assessment with Moose at Benevol 2010
 
Helping you reengineering your legacy
Helping you reengineering your legacyHelping you reengineering your legacy
Helping you reengineering your legacy
 
History Analysis (EVO 2008)
History Analysis (EVO 2008)History Analysis (EVO 2008)
History Analysis (EVO 2008)
 
Reverse Engineering Techniques 2007-11-29
Reverse Engineering Techniques 2007-11-29 Reverse Engineering Techniques 2007-11-29
Reverse Engineering Techniques 2007-11-29
 
A Moose Slideshow
A Moose SlideshowA Moose Slideshow
A Moose Slideshow
 
The humane software assessment (Choose Forum 2009)
The humane software assessment (Choose Forum 2009)The humane software assessment (Choose Forum 2009)
The humane software assessment (Choose Forum 2009)
 

Mehr von Jorge Ressia

Object-Centric Reflection - Thesis Defense
Object-Centric Reflection - Thesis DefenseObject-Centric Reflection - Thesis Defense
Object-Centric Reflection - Thesis DefenseJorge Ressia
 
Object-Centric Reflection - ESUG 2012
Object-Centric Reflection - ESUG 2012Object-Centric Reflection - ESUG 2012
Object-Centric Reflection - ESUG 2012Jorge Ressia
 
Object-Centric Debugging
Object-Centric DebuggingObject-Centric Debugging
Object-Centric DebuggingJorge Ressia
 
SDE - Dynamic Analysis
SDE - Dynamic AnalysisSDE - Dynamic Analysis
SDE - Dynamic AnalysisJorge Ressia
 
Bifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseBifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseJorge Ressia
 
Talents Presentation at ESUG 2011
Talents Presentation at ESUG 2011Talents Presentation at ESUG 2011
Talents Presentation at ESUG 2011Jorge Ressia
 
Domain-Specific Profiling - TOOLS 2011
Domain-Specific Profiling - TOOLS 2011Domain-Specific Profiling - TOOLS 2011
Domain-Specific Profiling - TOOLS 2011Jorge Ressia
 
Subjectopia tools2011
Subjectopia tools2011Subjectopia tools2011
Subjectopia tools2011Jorge Ressia
 
Advanced OO Design
Advanced OO DesignAdvanced OO Design
Advanced OO DesignJorge Ressia
 
Live featureanalysis
Live featureanalysisLive featureanalysis
Live featureanalysisJorge Ressia
 

Mehr von Jorge Ressia (12)

Object-Centric Reflection - Thesis Defense
Object-Centric Reflection - Thesis DefenseObject-Centric Reflection - Thesis Defense
Object-Centric Reflection - Thesis Defense
 
Object-Centric Reflection - ESUG 2012
Object-Centric Reflection - ESUG 2012Object-Centric Reflection - ESUG 2012
Object-Centric Reflection - ESUG 2012
 
Object-Centric Debugging
Object-Centric DebuggingObject-Centric Debugging
Object-Centric Debugging
 
SDE - Dynamic Analysis
SDE - Dynamic AnalysisSDE - Dynamic Analysis
SDE - Dynamic Analysis
 
Bifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk LooseBifrost: Setting Smalltalk Loose
Bifrost: Setting Smalltalk Loose
 
Talents Presentation at ESUG 2011
Talents Presentation at ESUG 2011Talents Presentation at ESUG 2011
Talents Presentation at ESUG 2011
 
Domain-Specific Profiling - TOOLS 2011
Domain-Specific Profiling - TOOLS 2011Domain-Specific Profiling - TOOLS 2011
Domain-Specific Profiling - TOOLS 2011
 
Subjectopia tools2011
Subjectopia tools2011Subjectopia tools2011
Subjectopia tools2011
 
Advanced OO Design
Advanced OO DesignAdvanced OO Design
Advanced OO Design
 
Opal compiler
Opal compilerOpal compiler
Opal compiler
 
Live featureanalysis
Live featureanalysisLive featureanalysis
Live featureanalysis
 
Runtime evolution
Runtime evolutionRuntime evolution
Runtime evolution
 

Kürzlich hochgeladen

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Kürzlich hochgeladen (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

05 Problem Detection

  • 1. Metrics and Problem Detection Jorge Ressia
  • 2. Software is complex. 29% Succeeded 18% Failed 53% Challenged The Standish Group, 2004
  • 3. How large is your project? 1’000’000 lines of code * 2 = 2’000’000 seconds / 3600 = 560 hours / 8 = 70 days / 20 = 3 months
  • 4. } } { { } } { { g rin ee gin en d ar rw fo
  • 5. fo rw ar d en gin ee rin g { { { { { { } { { } } actual development } } } { } } }
  • 6. What is the current state? fo rw ar What should we do? d en Where to start? gin ee How to proceed? rin g { { { { { { } { { } } actual development } } } { } } }
  • 7. fo rw g rin ar ee d gin en gin en ee e rs rin ve g re { { { { { { } { { } } actual development } } } { } } }
  • 8. Reverse engineering is analyzing a subject system to: identify components and their relationships, and create more abstract representations. Chikofky & Cross, 90
  • 9. quality? udg e its to j How { { { { } } } } { } A large system contains lots of details.
  • 11. 1 Metrics 2Design Problems 3 Code Duplication
  • 12. Metrics 1
  • 13. Youcannot control what you cannot measure. Tom de Marco
  • 14. Metrics are functions that assign numbers to products, processes and resources.
  • 15. Software metrics are measurements which relate to software systems, processes or related documents.
  • 16. Metrics compress system traits into numbers.
  • 17. Let’s see some examples...
  • 18. Examples of size metrics NOM - number of methods NOA - number of attributes LOC - number of lines of code NOS - number of statements NOC - number of children Lorenz, Kidd, 1994 Chidamber, Kemerer, 1994
  • 19. McCabe cyclomatic complexity (CYCLO) counts the number of independent paths through the code of a function. McCabe, 1977  it reveals the minimum number of tests to write  interpretation can’t directly lead to improvement action
  • 20. Weighted Method Count (WMC) sums up the complexity of class’ methods (measured by the metric of your choice; usually CYCLO). Chidamber, Kemerer, 1994  it is configurable, thus adaptable to our precise needs  interpretation can’t directly lead to improvement action
  • 21. Depth of Inheritance Tree (DIT) is the (maximum) depth level of a class in a class hierarchy. Chidamber, Kemerer, 1994  inheritance is measured  only the potential and not the real impact is quantified
  • 22. Coupling between objects (CBO) shows the number of classes from which methods or attributes are used. Chidamber, Kemerer, 1994  it takes into account real dependencies not just declared ones  no differentiation of types and/or intensity of coupling
  • 23. Tight Class Cohesion (TCC) counts the relative number of method-pairs that access attributes of the class in common. Bieman, Kang, 1995 TCC = 2 / 10 = 0.2  interpretation can lead to improvement action  ratio values allow comparison between systems
  • 24. Access To Foreign Data (ATFD) counts how many attributes from other classes are accessed directly from a measured class. Marinescu 2006
  • 25. ...
  • 28. Metrics Assess and Improve Quality! ea lly? R
  • 30. Problem 1: metrics granularity ? capture symptoms, not causes of problems in isolation, they don’t lead to improvement solutions Problem 2: implicit mapping we don’t reason in terms of metrics, but in terms of design principles
  • 31. 2 big obstacles in using metrics: Thresholds make metrics hard to interpret Granularity make metrics hard to use in isolation
  • 32. Can metrics help me in what I really care for? :)
  • 33. et rics! ith m o do w thi ng t an t no Iw fo rw ar How do I understand code? d en How do I improve code? gin ee rin g { { { { { { } { { } } actual development } } } { } } }
  • 34. How to get an initial understanding of a system?
  • 35. Metric Value LOC 35175 NOM 3618 NOC 384 CYCLO 5579 NOP 19 CALLS 15128 FANOUT 8590 AHH 0.12 ANDC 0.31
  • 36. Metric Value LOC 35175 NOM 3618 NOC 384 CYCLO 5579 NOP 19 CALLS 15128 FANOUT 8590 t? wha AHH nd now 0.12 A ANDC 0.31
  • 37. We need means to compare.
  • 38. hierarchies? coupling?
  • 39. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 Inheritance ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT Size Communication
  • 40. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT Size
  • 41. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT Communication
  • 42. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 Inheritance ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT
  • 43. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT
  • 44. Java C++ LOW AVG HIGH LOW AVG HIGH CYCLO/LOC 0.16 0.20 0.24 0.20 0.25 0.30 LOC/NOM 7 10 13 5 10 16 NOM/NOC 4 7 10 4 9 15 ...
  • 45. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 ANDC 0.31 AHH 0.12 20.21 NOP 19 9.42 NOC 384 9.72 NOM 3618 NOM 418 0.15 LOC 35175 15128 CALLS 0.56 CYCLO 5579 8590 FANOUT close to high close to average close to low
  • 46. The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006 close to high close to average close to low
  • 47. rics! met do with o ng t n othi Iw ant fo rw ar How do I understand code? d en How do I improve code? gin ee rin g { { { { { { } { { } } actual development } } } { } } }
  • 48. How do I improve code?
  • 49. Quality is more than 0 bugs. Breaking design principles, rules and best practices deteriorates the code; it leads to design problems.
  • 50. Imagine changing just a small design fragment and33% of all classes would require changes
  • 51. expensive Design problems are frequent unavoidable ? e them inat elim and detect How to
  • 52. God Classes tend to centralize the intelligence of the system, to do everything and to use data from small data-classes. Riel, 1996
  • 53. God Classes tend to centralize the intelligence of the system, to do everything and to use data from small data-classes.
  • 54. God Classes centralize the intelligence of the system, do everything and use data from small data-classes.
  • 55. God Classes are complex, are not cohesive, access external data.
  • 56. God Classes are complex, WMC is high are not cohesive, TCC is low access external data. ATFD more than few su sing u erie to q s cs in rator etri pe se m ical o C o mpo log
  • 57. Detection Strategies are metric-based queries to detect design flaws. Lanza, Marinescu 2006 Rule 1 METRIC 1 > Threshold 1 AND Quality problem Rule 2 METRIC 2 < Threshold 2
  • 58. A God Class centralizes too much intelligence in the system. Lanza, Marinescu 2006 Class uses directly more than a few attributes of other classes ATFD > FEW Functional complexity of the class is very high AND GodClass WMC ! VERY HIGH Class cohesion is low TCC < ONE THIRD
  • 59. An Envious Method is more interested in data from a handful of classes. Lanza, Marinescu 2006 Method uses directly more than a few attributes of other classes ATFD > FEW Method uses far more attributes of other classes than its own AND Feature Envy LAA < ONE THIRD The used quot;foreignquot; attributes belong to very few other classes FDP ! FEW
  • 60. Data Classes are dumb data holders. Lanza, Marinescu 2006 Interface of class reveals data rather than offering services WOC < ONE THIRD AND Data Class Class reveals many attributes and is not complex
  • 61. Data Classes are dumb data holders. Lanza, Marinescu 2006 More than a few public data NOAP + NOAM > FEW AND Complexity of class is not high WMC < HIGH Class reveals many OR attributes and is not Class has many public complex data NOAP + NOAM > MANY AND Complexity of class is not very high WMC < VERY HIGH
  • 62. Shotgun Surgery depicts that a change in an operation triggers many (small) in a lot of different operation and classes. Lanza, Marinescu 2006
  • 64. What is Code Duplication? so f it? pro blem he ta re t a Wh
  • 65. Code Duplication Detection Lexical Equivalence Syntactical Equivalence Semantic Equivalence
  • 66. Visualization of Copied Code Sequences File A File B File A File B
  • 67. Transformation Comparison Source Code Transformed Code Duplication Data Author Level Transformed Code Comparison Technique Johnson 94 Lexical Substrings String-Matching Ducasse 99 Lexical Normalized Strings String-Matching Baker 95 Syntactical Parameterized Strings String-Matching Mayrand 96 Syntactical Metrics Tuples Discrete comparison Kontogiannis 97 Syntactical Metrics Tuples Euclidean distance Baxter 98 Syntactical AST Tree-Matching
  • 68. Noise Elimination … //assign same fastid as container fastid=NULL; fastid = NULL; constchar*fidptr=get_fastid(); const char* fidptr = get_fastid(); if(fidptr!=NULL) if(fidptr != NULL) { intl=strlen(fidptr) int l = strlen(fidptr); fastid = newchar[l+] fastid = newchar[ l + 1 ];
  • 70. lines from source a b c d a b c d lines from source
  • 71. lines from source a b c d a x y d lines from source
  • 72. lines from source a b c a b x y c lines from source
  • 73. lines from source a x b x c x d x lines from source
  • 74. lines from source 2 lines from source 1
  • 75. lines from source 2 lines from source 1
  • 76. lines from source 2 lines from source 1 exact chunk
  • 77. lines from source 2 lines from source 1 exact line chunk bias
  • 78. lines from source 2 lines from source 1 exact line exact chunk bias chunk
  • 79. Significant Duplication: - It is the largest possible duplication chain uniting all exact clones that are close enough to each other. - The duplication is large enough. Lanza, Marinescu 2006
  • 80. 1 Metrics 2Design Problems 3 Code Duplication
  • 81. Shotgun Surgery has uses is has (partial) Feature Data Envy uses Class is partially God has Intensive Class Coupling Brain has has Method Extensive Brain has Significant Coupling Class Duplication has is is has Refused is Tradition Parent Breaker Bequest has (subclass) Futile Hierarchy Lanza, Marinescu 2006 Identity Collaboration Classification Disharmonies Disharmonies Disharmonies
  • 82. Follow a clear and repeatable process mb ers! u ms of n in ter qu ality ut n abo easo Don’t r
  • 83. QA is part of the the Development Process http://loose.upt.ro/incode
  • 84. Tudor Gîrba www.tudorgirba.com Jorge Ressia creativecommons.org/licenses/by/3.0/