SlideShare a Scribd company logo
A Domain Analysis to Specify Design
Defects and Generate Detection Algorithms


      Naouel Moha, Yann-Gaël Guéhéneuc,
    Anne-Françoise Le Meur, Laurence Duchien


              Ptidej Team, GEODES, Université de Montréal, Canada
      LIFL, INRIA Lille - Nord Europe / ADAM Team, Université de Lille, France


                                  FASE’08
                          29 March - 6 April, 2008
Context




Moha ©    A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   2
Context




Moha ©    A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   3
What Kind of Defects ?
    Design Patterns are “good” solutions to recurring design problems

    Design Defects (DDs)
         are “bad” solutions to recurring problems
         2 categories:
            High-level (global) problems: antipatterns [Brown 98]
            Low-level (local) problems: code smells* [Fowler 99]

    “ deviations from specifications or expectations which might lead to
≠
    failures in operation ”


    * Some code smells can be considered as high-level DDs


Moha ©              A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   4
What Kind of Defects ?
  2 examples of high-level DDs [Brown 98]

                            Blob (God Class)
                            “ Procedural-style design leads to one object with a
                            lion’s share of the responsibilities while most other
                            objects only hold data or execute simple processes ”


                                 Large controller class

                                 Many fields and methods with a low cohesion*

                                 Dependent on the data stored in associated
                                 data classes

                                    *How closely the methods are related to the instance
                                     variables in the class.
Moha ©        A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   5
What Kind of Defects ?
  2 examples of high-level DDs [Brown 98]

                            Spaghetti Code
                            “ Ad hoc software structure makes it difficult to extend
                            and optimize code. ”


                                 Procedural thinking in OO programming

                                 Lack of structure : no inheritance, no reuse, no
                                 polymorphism

                                 Long methods process oriented with no
                                 parameters and low cohesion

                                 Classes with procedural names

                                 Use of global variables for processing
Moha ©        A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   6
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                7
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                8
Method DECOR




                                       Specification




                                                           Processing




                                                                                                     Validation
                                                                              Detection
                 Analysis
                 Domain




     Contributions
         Domain analysis of DDs and domain-specific language

         Explicit process for the specifications

         Validation : first study on both precision and recall

Moha ©               A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                9
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                10
DECOR Method




Domain Analysis
                                                                               On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                       Source code                      Source code
                                                                                                      1                                       2                                  3                                 4                                 5




                                                                                                                              Specification
                                                                                                                                                                                       of the system                    of the system




                                                                                                                                                                    Processing




                                                                                                                                                                                                                                        Validation
                                                                                                           Vocabulary




                                                                                                                                                                                                       Detection
                                                                                                Analysis
                                                                                                Domain
                                                                   Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                      of design defects                                                                                              specifications                     classes                           design defects
                                                                                                           Taxonomy
                                                                     Brown et al. (1998)
                                                                      Demeyer (2002)
                                                                       Dudney (2003)
                                                                                                                                                                                                 Marinescu (2004)           Marinescu (2004)
                                                                       Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                 Alikacem (2006)             Munro (2005)
                                                                        Riel (1996)                                      Munro (2005)
                                                                                                                                                                                        Travassos : manual detection (1999)
                                                                      Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                        Tools: SmallLint, PMD, CROCOPAT




                                                          The Spaghetti Code is an
                                                        antipattern that is characteristic
             Chapter 1                                  of procedural thinking in object-
                                                        oriented programming. Spaghetti
                                                        Code is revealed by classes with
     Descriptions of antipatterns                       no structure, declaring long
                                                        methods with no parameters,
                                                        and utilising global variables for
                                                        processing. Names of classes
                                                        and methods may suggest
                                                        procedural          programming.
                                                        Spaghetti Code does not exploit
                                                        and prevents the use of object-
                                                        orientation          mechanisms,
                                                        polymorphism and inheritance.



Moha ©           A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       11
DECOR Method




Domain Analysis
                                                                                 On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                         Source code                      Source code
                                                                                                        1                                       2                                  3                                 4                                 5




                                                                                                                                Specification
                                                                                                                                                                                         of the system                    of the system




                                                                                                                                                                      Processing




                                                                                                                                                                                                                                          Validation
                                                                                                             Vocabulary




                                                                                                                                                                                                         Detection
                                                                                                  Analysis
                                                                                                  Domain
                                                                     Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                        of design defects                                                                                              specifications                     classes                           design defects
                                                                                                             Taxonomy
                                                                       Brown et al. (1998)
                                                                        Demeyer (2002)
                                                                         Dudney (2003)
                                                                                                                                                                                                   Marinescu (2004)           Marinescu (2004)
                                                                         Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                   Alikacem (2006)             Munro (2005)
                                                                          Riel (1996)                                      Munro (2005)
                                                                                                                                                                                          Travassos : manual detection (1999)
                                                                        Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                          Tools: SmallLint, PMD, CROCOPAT




                                                            The Spaghetti Code is an
                                                          antipattern that is characteristic
               Chapter 1                                  of procedural thinking in object-
                                                          oriented programming. Spaghetti
                                                          Code is revealed by classes with
     Descriptions of antipatterns                         no structure, declaring long
                                                          methods with no parameters,
                                                          and utilising global variables for
         Identification of Key Concepts                   processing. Names of classes
                                                          and methods may suggest
                                                          procedural          programming.
                                                          Spaghetti Code does not exploit
                                                          and prevents the use of object-
                                                          orientation          mechanisms,
                                                          polymorphism and inheritance.



Moha ©             A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       12
DECOR Method




Domain Analysis
                                                                       On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                               Source code                      Source code
                                                                                              1                                       2                                  3                                 4                                 5




                                                                                                                      Specification
                                                                                                                                                                               of the system                    of the system




                                                                                                                                                            Processing




                                                                                                                                                                                                                                Validation
                                                                                                   Vocabulary




                                                                                                                                                                                               Detection
                                                                                        Analysis
                                                                                        Domain
                                                           Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                              of design defects                                                                                              specifications                     classes                           design defects
                                                                                                   Taxonomy
                                                             Brown et al. (1998)
                                                              Demeyer (2002)
                                                               Dudney (2003)
                                                                                                                                                                                         Marinescu (2004)           Marinescu (2004)
                                                               Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                         Alikacem (2006)             Munro (2005)
                                                                Riel (1996)                                      Munro (2005)
                                                                                                                                                                                Travassos : manual detection (1999)
                                                              Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                Tools: SmallLint, PMD, CROCOPAT




Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       13
DECOR Method




Domain Analysis
                                                                       On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                               Source code                      Source code
                                                                                              1                                       2                                  3                                 4                                 5




                                                                                                                      Specification
                                                                                                                                                                               of the system                    of the system




                                                                                                                                                            Processing




                                                                                                                                                                                                                                Validation
                                                                                                   Vocabulary




                                                                                                                                                                                               Detection
                                                                                        Analysis
                                                                                        Domain
                                                           Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                              of design defects                                                                                              specifications                     classes                           design defects
                                                                                                   Taxonomy
                                                             Brown et al. (1998)
                                                              Demeyer (2002)
                                                               Dudney (2003)
                                                                                                                                                                                         Marinescu (2004)           Marinescu (2004)
                                                               Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                         Alikacem (2006)             Munro (2005)
                                                                Riel (1996)                                      Munro (2005)
                                                                                                                                                                                Travassos : manual detection (1999)
                                                              Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                Tools: SmallLint, PMD, CROCOPAT




Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       14
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                15
DECOR Method




Specifications
                                                                                     On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                             Source code                      Source code
                                                                                                            1                                       2                                  3                                 4                                 5




                                                                                                                                    Specification
                                                                                                                                                                                             of the system                    of the system




                                                                                                                                                                          Processing




                                                                                                                                                                                                                                              Validation
                                                                                                                 Vocabulary




                                                                                                                                                                                                             Detection
                                                                                                      Analysis
                                                                                                      Domain
                                                                         Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                            of design defects                                                                                              specifications                     classes                           design defects
                                                                                                                 Taxonomy
                                                                           Brown et al. (1998)
                                                                            Demeyer (2002)
                                                                             Dudney (2003)
                                                                                                                                                                                                       Marinescu (2004)           Marinescu (2004)
                                                                             Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                       Alikacem (2006)             Munro (2005)
                                                                              Riel (1996)                                      Munro (2005)
                                                                                                                                                                                              Travassos : manual detection (1999)
                                                                            Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                              Tools: SmallLint, PMD, CROCOPAT




SADSL (Software Architectural Defect Specification Language)
         Language based on a meta-model for specifying DDs


  CODESMELL   define   LongMethod            as    METRIC     LOC_METHOD with                                     VERY HIGH and 10.0 ;

  CODESMELL   define   NoParameter           as    METRIC     NMNOPARAM                   with                    VERY HIGH and 5.0 ;
  CODESMELL   define   NoInheritance         as    METRIC     DIT                         with                    1 and 0.0 ;
  CODESMELL   define   NoPolymorphism as           STRUC      NO_POLYMORPHISM ;

  CODESMELL   define   ProceduralName as           LEXIC      CLASS_NAME with                                     (Make, Create, Exec) ;

  CODESMELL   define   GlobalVariable as           STRUC      USE_GLOBAL_VARIABLE ;


  ANTIPATTERN define SpaghettiCode           as {
         ((LongMethod INTER NoParameter) INTER (NoInheritance UNION NoPolymorphism))

     INTER
         (ProceduralName UNION UseGlobalVariable) } ;




Moha ©                 A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       16
DECOR Method




Specifications
                                                                                     On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                             Source code                      Source code
                                                                                                            1                                       2                                  3                                 4                                 5




                                                                                                                                    Specification
                                                                                                                                                                                             of the system                    of the system




                                                                                                                                                                          Processing




                                                                                                                                                                                                                                              Validation
                                                                                                                 Vocabulary




                                                                                                                                                                                                             Detection
                                                                                                      Analysis
                                                                                                      Domain
                                                                         Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                            of design defects                                                                                              specifications                     classes                           design defects
                                                                                                                 Taxonomy
                                                                           Brown et al. (1998)
                                                                            Demeyer (2002)
                                                                             Dudney (2003)
                                                                                                                                                                                                       Marinescu (2004)           Marinescu (2004)
                                                                             Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                       Alikacem (2006)             Munro (2005)
                                                                              Riel (1996)                                      Munro (2005)
                                                                                                                                                                                              Travassos : manual detection (1999)
                                                                            Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                              Tools: SmallLint, PMD, CROCOPAT




SADSL (Software Architectural Defect Specification Language)
         Language based on a meta-model for specifying DDs


  CODESMELL   define   LongMethod            as    METRIC     LOC_METHOD with                                     VERY HIGH and 10.0 ;

  CODESMELL   define   NoParameter           as    METRIC     NMNOPARAM                   with                    VERY HIGH and 5.0 ;
  CODESMELL   define   NoInheritance         as    METRIC     DIT                         with                    1 and 0.0 ;
  CODESMELL   define   NoPolymorphism as            STRUC     NO_POLYMORPHISM ;
  CODESMELL   define   ProceduralName as            LEXIC     CLASS_NAME with                                     (Make, Create, Exec) ;
  CODESMELL   define   GlobalVariable as           STRUC      USE_GLOBAL_VARIABLE ;



  ANTIPATTERN define SpaghettiCode           as {
         ((LongMethod INTER NoParameter) INTER (NoInheritance UNION NoPolymorphism))

     INTER
         (ProceduralName UNION UseGlobalVariable) } ;




Moha ©                 A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       17
DECOR Method




 Specifications
                                                                              On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                      Source code                      Source code
                                                                                                     1                                       2                                  3                                 4                                 5




                                                                                                                             Specification
                                                                                                                                                                                      of the system                    of the system




                                                                                                                                                                   Processing




                                                                                                                                                                                                                                       Validation
                                                                                                          Vocabulary




                                                                                                                                                                                                      Detection
                                                                                               Analysis
                                                                                               Domain
                                                                  Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                     of design defects                                                                                              specifications                     classes                           design defects
                                                                                                          Taxonomy
                                                                    Brown et al. (1998)
                                                                     Demeyer (2002)
                                                                      Dudney (2003)
                                                                                                                                                                                                Marinescu (2004)           Marinescu (2004)
                                                                      Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                Alikacem (2006)             Munro (2005)
                                                                       Riel (1996)                                      Munro (2005)
                                                                                                                                                                                       Travassos : manual detection (1999)
                                                                     Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                       Tools: SmallLint, PMD, CROCOPAT




Meta-model SADDL (Software Architectural Defect Definition Language)




Moha ©          A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       18
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                19
Method DECOR




                               Specification




                                                 Generation




                                                                                             Validation
                                                 Algorithm




                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                20
DECOR Method




Algorithm Generation
                                                                       On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                               Source code                      Source code
                                                                                              1                                       2                                  3                                 4                                 5




                                                                                                                      Specification
                                                                                                                                                                               of the system                    of the system




                                                                                                                                                            Processing




                                                                                                                                                                                                                                Validation
                                                                                                   Vocabulary




                                                                                                                                                                                               Detection
                                                                                        Analysis
                                                                                        Domain
                                                           Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                              of design defects                                                                                              specifications                     classes                           design defects
                                                                                                   Taxonomy
                                                             Brown et al. (1998)
                                                              Demeyer (2002)
                                                               Dudney (2003)
                                                                                                                                                                                         Marinescu (2004)           Marinescu (2004)
                                                               Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                         Alikacem (2006)             Munro (2005)
                                                                Riel (1996)                                      Munro (2005)
                                                                                                                                                                                Travassos : manual detection (1999)
                                                              Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                Tools: SmallLint, PMD, CROCOPAT




Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       21
DECOR Method




Algorithm Generation
                                                                       On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                               Source code                      Source code
                                                                                              1                                       2                                  3                                 4                                 5




                                                                                                                      Specification
                                                                                                                                                                               of the system                    of the system




                                                                                                                                                            Processing




                                                                                                                                                                                                                                Validation
                                                                                                   Vocabulary




                                                                                                                                                                                               Detection
                                                                                        Analysis
                                                                                        Domain
                                                           Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                              of design defects                                                                                              specifications                     classes                           design defects
                                                                                                   Taxonomy
                                                             Brown et al. (1998)
                                                              Demeyer (2002)
                                                               Dudney (2003)
                                                                                                                                                                                         Marinescu (2004)           Marinescu (2004)
                                                               Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                         Alikacem (2006)             Munro (2005)
                                                                Riel (1996)                                      Munro (2005)
                                                                                                                                                                                Travassos : manual detection (1999)
                                                              Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                Tools: SmallLint, PMD, CROCOPAT




Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       22
DECOR Method




Algorithm Generation
                                                                       On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                               Source code                      Source code
                                                                                              1                                       2                                  3                                 4                                 5




                                                                                                                      Specification
                                                                                                                                                                               of the system                    of the system




                                                                                                                                                            Processing




                                                                                                                                                                                                                                Validation
                                                                                                   Vocabulary




                                                                                                                                                                                               Detection
                                                                                        Analysis
                                                                                        Domain
                                                           Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                              of design defects                                                                                              specifications                     classes                           design defects
                                                                                                   Taxonomy
                                                             Brown et al. (1998)
                                                              Demeyer (2002)
                                                               Dudney (2003)
                                                                                                                                                                                         Marinescu (2004)           Marinescu (2004)
                                                               Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                         Alikacem (2006)             Munro (2005)
                                                                Riel (1996)                                      Munro (2005)
                                                                                                                                                                                Travassos : manual detection (1999)
                                                              Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                Tools: SmallLint, PMD, CROCOPAT




         Consistency and domain-specific analyses
           - Verify that specifications are not inconsistent, redundant,
             or incomplete

          - Ex: 2 rules with same names but different properties
                2 rules with different names but identical properties



Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       23
DECOR Method




Algorithm Generation
                                                                                   On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                           Source code                      Source code
                                                                                                          1                                       2                                  3                                 4                                 5




                                                                                                                                  Specification
                                                                                                                                                                                           of the system                    of the system




                                                                                                                                                                        Processing




                                                                                                                                                                                                                                            Validation
                                                                                                               Vocabulary




                                                                                                                                                                                                           Detection
                                                                                                    Analysis
                                                                                                    Domain
                                                                       Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                          of design defects                                                                                              specifications                     classes                           design defects
                                                                                                               Taxonomy
                                                                         Brown et al. (1998)
                                                                          Demeyer (2002)
                                                                           Dudney (2003)
                                                                                                                                                                                                     Marinescu (2004)           Marinescu (2004)
                                                                           Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                     Alikacem (2006)             Munro (2005)
                                                                            Riel (1996)                                      Munro (2005)
                                                                                                                                                                                            Travassos : manual detection (1999)
                                                                          Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                            Tools: SmallLint, PMD, CROCOPAT




Complexity : O((c+op) X n)                   SAD Framework
   c : number of properties                  -        Meta-model to represent OO programs
   op : number of operators                  -        Repository of metrics
   n : number of classes
                                             -        Services to analyse structural relationships
                                             -        Services to perform structural and lexical analyses




Moha ©               A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       24
DECOR Method




Algorithm Generation
                                                                             On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                     Source code                      Source code
                                                                                                    1                                       2                                  3                                 4                                 5




                                                                                                                            Specification
                                                                                                                                                                                     of the system                    of the system




                                                                                                                                                                  Processing




                                                                                                                                                                                                                                      Validation
                                                                                                         Vocabulary




                                                                                                                                                                                                     Detection
                                                                                              Analysis
                                                                                              Domain
                                                                 Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                    of design defects                                                                                              specifications                     classes                           design defects
                                                                                                         Taxonomy
                                                                   Brown et al. (1998)
                                                                    Demeyer (2002)
                                                                     Dudney (2003)
                                                                                                                                                                                               Marinescu (2004)           Marinescu (2004)
                                                                     Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                               Alikacem (2006)             Munro (2005)
                                                                      Riel (1996)                                      Munro (2005)
                                                                                                                                                                                      Travassos : manual detection (1999)
                                                                    Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                      Tools: SmallLint, PMD, CROCOPAT




                                                     1 public class <CODESMELL>Detection
                                                     2    extends CodeSmellDetection
                                                     3    implements ICodeSmellDetection {
                                                     4    public Set performDetection() {
                                                     5      IClass c = iteratorOnClasses.next();
                                                     6      LOCofSetOfClasses.add(
                                                     7      Metrics.compute(<METRIC>, c));
                                                     8      ...
                                                     9      BoxPlot boxPlot = new BoxPlot(
                                                     10       <METRIC>ofSetOfClasses, <FUZZINESS>);
                                                     11     Map setOfOutliers =
                                                     12       boxPlot.<ORDINAL_VALUE>();
                                                     13     ...
                                                     14     suspiciousCodeSmells.add( new CodeSmell(
                                                     15       <CODESMELL>, setOfOutliers));
                                                     16     ...
                                                     17     return suspiciousCodeSmells;
                                                     18 }


         Visitor                                                          Template




Moha ©         A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       25
DECOR Method




Algorithm Generation
                                                                             On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                     Source code                      Source code
                                                                                                    1                                       2                                  3                                 4                                 5




                                                                                                                            Specification
                                                                                                                                                                                     of the system                    of the system




                                                                                                                                                                  Processing




                                                                                                                                                                                                                                      Validation
                                                                                                         Vocabulary




                                                                                                                                                                                                     Detection
                                                                                              Analysis
                                                                                              Domain
                                                                 Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                    of design defects                                                                                              specifications                     classes                           design defects
                                                                                                         Taxonomy
                                                                   Brown et al. (1998)
                                                                    Demeyer (2002)
                                                                     Dudney (2003)
                                                                                                                                                                                               Marinescu (2004)           Marinescu (2004)
                                                                     Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                               Alikacem (2006)             Munro (2005)
                                                                      Riel (1996)                                      Munro (2005)
                                                                                                                                                                                      Travassos : manual detection (1999)
                                                                    Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                      Tools: SmallLint, PMD, CROCOPAT




         Visitor                                                 Generated Code




Moha ©         A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       26
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                27
Method DECOR




                               Specification




                                                   Processing




                                                                                             Validation
                                                                      Detection
         Analysis
         Domain




Moha ©       A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                28
DECOR Method




 Experiments
                                                                                   On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                           Source code                      Source code
                                                                                                          1                                       2                                  3                                 4                                 5




                                                                                                                                  Specification
                                                                                                                                                                                           of the system                    of the system




                                                                                                                                                                        Processing




                                                                                                                                                                                                                                            Validation
                                                                                                               Vocabulary




                                                                                                                                                                                                           Detection
                                                                                                    Analysis
                                                                                                    Domain
                                                                       Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                          of design defects                                                                                              specifications                     classes                           design defects
                                                                                                               Taxonomy
                                                                         Brown et al. (1998)
                                                                          Demeyer (2002)
                                                                           Dudney (2003)
                                                                                                                                                                                                     Marinescu (2004)           Marinescu (2004)
                                                                           Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                     Alikacem (2006)             Munro (2005)
                                                                            Riel (1996)                                      Munro (2005)
                                                                                                                                                                                            Travassos : manual detection (1999)
                                                                          Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                            Tools: SmallLint, PMD, CROCOPAT




Goal : Validate the generated algorithms in terms of precision and recall
Xerces: 71,217 LOC, 513 classes and 162 interfaces

                         Nb of          Existing            Detected                                                                                                                                            Detection
         Defects                                                                           Precision                                                         Recall
                        classes         Defects             Defects                                                                                                                                               Time

Blob                                   39    (7,6%)        44    (8,6%)                          88,6%                                                         100%                                                          2,45s

Functional Decomp.                     15    (2,9%)        29    (5,6%)                          51,7%                                                         100%                                                          0,91s
                           513
Spaghetti Code                         46    (9,0%)        76 (14,8%)                            60,5%                                                         100%                                                          0,23s

Swiss Army Knife                       23    (4,5%)        56 (10,9%)                            41,1%                                                         100%                                                          0,08s




Moha ©               A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       29
Demonstration




Moha ©   A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   30
Conclusion
    Method DECOR
    Automate the generation of detection algorithms from specifications
    written using a domain-specific language

    Contributions
         The domain-specific language defined from a domain analysis

         Explicit process for the generation of detection algorithms

         Validation in terms of precision and recall

    Future Work
         Experiments on other systems and defects

         Comparison with existing approaches

         Correction of defects (in progress)
Moha ©             A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   31
Questions
         Contact: mohanaou@iro.umontreal.ca
                  http://www-etud.iro.umontreal.ca/~mohanaou




         Thanks for your attention !

Moha ©                A Domain Analysis to Specify Design Defects and Generate Detection Algorithms   32
DECOR Method




Algorithm Generation
                                                                              On all defects                                                     On each defect                                                   On each system
                                                                                                                                                                                      Source code                      Source code
                                                                                                     1                                       2                                  3                                 4                                 5




                                                                                                                             Specification
                                                                                                                                                                                      of the system                    of the system




                                                                                                                                                                   Processing




                                                                                                                                                                                                                                       Validation
                                                                                                          Vocabulary




                                                                                                                                                                                                      Detection
                                                                                               Analysis
                                                                                               Domain
                                                                  Text-based descriptions                                                         Specifications                     Operational                      Suspicious                         Classes having
                                                                     of design defects                                                                                              specifications                     classes                           design defects
                                                                                                          Taxonomy
                                                                    Brown et al. (1998)
                                                                     Demeyer (2002)
                                                                      Dudney (2003)
                                                                                                                                                                                                Marinescu (2004)           Marinescu (2004)
                                                                      Fowler (1999)                                    Marinescu (2004)
                                                                                                                                                                                                Alikacem (2006)             Munro (2005)
                                                                       Riel (1996)                                      Munro (2005)
                                                                                                                                                                                       Travassos : manual detection (1999)
                                                                     Webster (1995)                                    Alikacem (2006)
                                                                                                                                                                                       Tools: SmallLint, PMD, CROCOPAT




  Box-plot for metrics with ordinal values




Moha ©          A Domain Analysis to Specify Design Defects and Generate Detection Algorithms                                                                                                                                                       33

More Related Content

PDF
ASE06.ppt
PDF
Uma Solução para Identificação da Causa Raiz de Problemas no Gerenciamento de...
PDF
Developing Software that Matters (condensed)
PDF
IWLCS'2007: Substructural Surrogates for Learning Decomposable Classification...
PDF
02 test automation functional testing (qtp)
PDF
Lafauci dv club oct 2006
PDF
Temarios etapa xxii
PPT
Infant's vision
ASE06.ppt
Uma Solução para Identificação da Causa Raiz de Problemas no Gerenciamento de...
Developing Software that Matters (condensed)
IWLCS'2007: Substructural Surrogates for Learning Decomposable Classification...
02 test automation functional testing (qtp)
Lafauci dv club oct 2006
Temarios etapa xxii
Infant's vision

Similar to FASE08.ppt (20)

PDF
PDF
Cascon06 tooldemo.ppt
PDF
Cascon06 tooldemo.ppt
PPTX
Quick fix generation for DSMLs
PDF
Cross-project defect prediction
PDF
Bonneau - Software and Systems - Spring Review 2012
PPTX
Blackboard DevCon 2012 - Ensuring Code Quality
PPT
Sonar En
PPTX
PDF
Open source
PDF
RTF - Prasad bhatt
PDF
Investor's Presentation
PPTX
Monitoreo y análisis de aplicaciones "Multi-Tier"
PDF
Pattern-Oriented-Memory-Forensics-Revised-Edition-Slides.pdf
PDF
The Next Static Code Analysis Tool - Today and Tomorrow
PPTX
Persistent Analytical Instrumentation Expertise
PPT
Preparing for the era of cloud computing: Towards a framework for selecting b...
PDF
MoDisco EclipseCon2010
PPTX
Statistical debuging for programs written in dynamic programming language ruby
Cascon06 tooldemo.ppt
Cascon06 tooldemo.ppt
Quick fix generation for DSMLs
Cross-project defect prediction
Bonneau - Software and Systems - Spring Review 2012
Blackboard DevCon 2012 - Ensuring Code Quality
Sonar En
Open source
RTF - Prasad bhatt
Investor's Presentation
Monitoreo y análisis de aplicaciones "Multi-Tier"
Pattern-Oriented-Memory-Forensics-Revised-Edition-Slides.pdf
The Next Static Code Analysis Tool - Today and Tomorrow
Persistent Analytical Instrumentation Expertise
Preparing for the era of cloud computing: Towards a framework for selecting b...
MoDisco EclipseCon2010
Statistical debuging for programs written in dynamic programming language ruby
Ad

More from Ptidej Team (20)

PDF
From IoT to Software Miniaturisation
PDF
Presentation
PDF
Presentation
PDF
Presentation
PDF
Presentation by Lionel Briand
PDF
Manel Abdellatif
PDF
Azadeh Kermansaravi
PDF
Mouna Abidi
PDF
CSED - Manel Grichi
PDF
Cristiano Politowski
PDF
Will io t trigger the next software crisis
PDF
PDF
Thesis+of+laleh+eshkevari.ppt
PDF
Thesis+of+nesrine+abdelkafi.ppt
PDF
Medicine15.ppt
PDF
Qrs17b.ppt
PDF
Icpc11c.ppt
PDF
Icsme16.ppt
PDF
Msr17a.ppt
PDF
Icsoc15.ppt
From IoT to Software Miniaturisation
Presentation
Presentation
Presentation
Presentation by Lionel Briand
Manel Abdellatif
Azadeh Kermansaravi
Mouna Abidi
CSED - Manel Grichi
Cristiano Politowski
Will io t trigger the next software crisis
Thesis+of+laleh+eshkevari.ppt
Thesis+of+nesrine+abdelkafi.ppt
Medicine15.ppt
Qrs17b.ppt
Icpc11c.ppt
Icsme16.ppt
Msr17a.ppt
Icsoc15.ppt
Ad

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Empathic Computing: Creating Shared Understanding
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
A comparative analysis of optical character recognition models for extracting...
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
Getting Started with Data Integration: FME Form 101
Empathic Computing: Creating Shared Understanding
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine Learning_overview_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25-Week II
Digital-Transformation-Roadmap-for-Companies.pptx

FASE08.ppt

  • 1. A Domain Analysis to Specify Design Defects and Generate Detection Algorithms Naouel Moha, Yann-Gaël Guéhéneuc, Anne-Françoise Le Meur, Laurence Duchien Ptidej Team, GEODES, Université de Montréal, Canada LIFL, INRIA Lille - Nord Europe / ADAM Team, Université de Lille, France FASE’08 29 March - 6 April, 2008
  • 2. Context Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 2
  • 3. Context Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 3
  • 4. What Kind of Defects ? Design Patterns are “good” solutions to recurring design problems Design Defects (DDs) are “bad” solutions to recurring problems 2 categories: High-level (global) problems: antipatterns [Brown 98] Low-level (local) problems: code smells* [Fowler 99] “ deviations from specifications or expectations which might lead to ≠ failures in operation ” * Some code smells can be considered as high-level DDs Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 4
  • 5. What Kind of Defects ? 2 examples of high-level DDs [Brown 98] Blob (God Class) “ Procedural-style design leads to one object with a lion’s share of the responsibilities while most other objects only hold data or execute simple processes ” Large controller class Many fields and methods with a low cohesion* Dependent on the data stored in associated data classes *How closely the methods are related to the instance variables in the class. Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 5
  • 6. What Kind of Defects ? 2 examples of high-level DDs [Brown 98] Spaghetti Code “ Ad hoc software structure makes it difficult to extend and optimize code. ” Procedural thinking in OO programming Lack of structure : no inheritance, no reuse, no polymorphism Long methods process oriented with no parameters and low cohesion Classes with procedural names Use of global variables for processing Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 6
  • 7. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 7
  • 8. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 8
  • 9. Method DECOR Specification Processing Validation Detection Analysis Domain Contributions Domain analysis of DDs and domain-specific language Explicit process for the specifications Validation : first study on both precision and recall Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 9
  • 10. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 10
  • 11. DECOR Method Domain Analysis On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT The Spaghetti Code is an antipattern that is characteristic Chapter 1 of procedural thinking in object- oriented programming. Spaghetti Code is revealed by classes with Descriptions of antipatterns no structure, declaring long methods with no parameters, and utilising global variables for processing. Names of classes and methods may suggest procedural programming. Spaghetti Code does not exploit and prevents the use of object- orientation mechanisms, polymorphism and inheritance. Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 11
  • 12. DECOR Method Domain Analysis On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT The Spaghetti Code is an antipattern that is characteristic Chapter 1 of procedural thinking in object- oriented programming. Spaghetti Code is revealed by classes with Descriptions of antipatterns no structure, declaring long methods with no parameters, and utilising global variables for Identification of Key Concepts processing. Names of classes and methods may suggest procedural programming. Spaghetti Code does not exploit and prevents the use of object- orientation mechanisms, polymorphism and inheritance. Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 12
  • 13. DECOR Method Domain Analysis On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 13
  • 14. DECOR Method Domain Analysis On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 14
  • 15. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 15
  • 16. DECOR Method Specifications On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT SADSL (Software Architectural Defect Specification Language) Language based on a meta-model for specifying DDs CODESMELL define LongMethod as METRIC LOC_METHOD with VERY HIGH and 10.0 ; CODESMELL define NoParameter as METRIC NMNOPARAM with VERY HIGH and 5.0 ; CODESMELL define NoInheritance as METRIC DIT with 1 and 0.0 ; CODESMELL define NoPolymorphism as STRUC NO_POLYMORPHISM ; CODESMELL define ProceduralName as LEXIC CLASS_NAME with (Make, Create, Exec) ; CODESMELL define GlobalVariable as STRUC USE_GLOBAL_VARIABLE ; ANTIPATTERN define SpaghettiCode as { ((LongMethod INTER NoParameter) INTER (NoInheritance UNION NoPolymorphism)) INTER (ProceduralName UNION UseGlobalVariable) } ; Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 16
  • 17. DECOR Method Specifications On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT SADSL (Software Architectural Defect Specification Language) Language based on a meta-model for specifying DDs CODESMELL define LongMethod as METRIC LOC_METHOD with VERY HIGH and 10.0 ; CODESMELL define NoParameter as METRIC NMNOPARAM with VERY HIGH and 5.0 ; CODESMELL define NoInheritance as METRIC DIT with 1 and 0.0 ; CODESMELL define NoPolymorphism as STRUC NO_POLYMORPHISM ; CODESMELL define ProceduralName as LEXIC CLASS_NAME with (Make, Create, Exec) ; CODESMELL define GlobalVariable as STRUC USE_GLOBAL_VARIABLE ; ANTIPATTERN define SpaghettiCode as { ((LongMethod INTER NoParameter) INTER (NoInheritance UNION NoPolymorphism)) INTER (ProceduralName UNION UseGlobalVariable) } ; Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 17
  • 18. DECOR Method Specifications On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Meta-model SADDL (Software Architectural Defect Definition Language) Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 18
  • 19. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 19
  • 20. Method DECOR Specification Generation Validation Algorithm Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 20
  • 21. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 21
  • 22. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 22
  • 23. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Consistency and domain-specific analyses - Verify that specifications are not inconsistent, redundant, or incomplete - Ex: 2 rules with same names but different properties 2 rules with different names but identical properties Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 23
  • 24. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Complexity : O((c+op) X n) SAD Framework c : number of properties - Meta-model to represent OO programs op : number of operators - Repository of metrics n : number of classes - Services to analyse structural relationships - Services to perform structural and lexical analyses Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 24
  • 25. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT 1 public class <CODESMELL>Detection 2 extends CodeSmellDetection 3 implements ICodeSmellDetection { 4 public Set performDetection() { 5 IClass c = iteratorOnClasses.next(); 6 LOCofSetOfClasses.add( 7 Metrics.compute(<METRIC>, c)); 8 ... 9 BoxPlot boxPlot = new BoxPlot( 10 <METRIC>ofSetOfClasses, <FUZZINESS>); 11 Map setOfOutliers = 12 boxPlot.<ORDINAL_VALUE>(); 13 ... 14 suspiciousCodeSmells.add( new CodeSmell( 15 <CODESMELL>, setOfOutliers)); 16 ... 17 return suspiciousCodeSmells; 18 } Visitor Template Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 25
  • 26. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Visitor Generated Code Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 26
  • 27. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 27
  • 28. Method DECOR Specification Processing Validation Detection Analysis Domain Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 28
  • 29. DECOR Method Experiments On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Goal : Validate the generated algorithms in terms of precision and recall Xerces: 71,217 LOC, 513 classes and 162 interfaces Nb of Existing Detected Detection Defects Precision Recall classes Defects Defects Time Blob 39 (7,6%) 44 (8,6%) 88,6% 100% 2,45s Functional Decomp. 15 (2,9%) 29 (5,6%) 51,7% 100% 0,91s 513 Spaghetti Code 46 (9,0%) 76 (14,8%) 60,5% 100% 0,23s Swiss Army Knife 23 (4,5%) 56 (10,9%) 41,1% 100% 0,08s Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 29
  • 30. Demonstration Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 30
  • 31. Conclusion Method DECOR Automate the generation of detection algorithms from specifications written using a domain-specific language Contributions The domain-specific language defined from a domain analysis Explicit process for the generation of detection algorithms Validation in terms of precision and recall Future Work Experiments on other systems and defects Comparison with existing approaches Correction of defects (in progress) Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 31
  • 32. Questions Contact: mohanaou@iro.umontreal.ca http://www-etud.iro.umontreal.ca/~mohanaou Thanks for your attention ! Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 32
  • 33. DECOR Method Algorithm Generation On all defects On each defect On each system Source code Source code 1 2 3 4 5 Specification of the system of the system Processing Validation Vocabulary Detection Analysis Domain Text-based descriptions Specifications Operational Suspicious Classes having of design defects specifications classes design defects Taxonomy Brown et al. (1998) Demeyer (2002) Dudney (2003) Marinescu (2004) Marinescu (2004) Fowler (1999) Marinescu (2004) Alikacem (2006) Munro (2005) Riel (1996) Munro (2005) Travassos : manual detection (1999) Webster (1995) Alikacem (2006) Tools: SmallLint, PMD, CROCOPAT Box-plot for metrics with ordinal values Moha © A Domain Analysis to Specify Design Defects and Generate Detection Algorithms 33