SlideShare a Scribd company logo
1 of 23
Download to read offline
A New Family of Software Anti-Patterns:
       Linguistic Anti-Patterns
Venera Arnaoudova1, Massimiliano Di Penta2, Giuliano
         Antoniol1,Yann-Gaël Guéhéneuc1
             1 ÉcolePolytechnique de Montréal, Canada
             2 University of Sannio, Benevento, Italy




                                1                       CSMR’13
Families of
   Patterns/Anti-Patterns
   • Patterns, e.g., Design


   • Anti-Patterns, e.g., Software Development


Venera Arnaoudova         2                CSMR’13
Source code lexicon
                                           i.e. vocabulary of your code

   • What do we know?
    • We should strive for good quality lexicon
   • How is quality of the lexicon measured?
    • English words, domain terms
    • Abbreviations, acronyms
    [Takang et al., ’96], [Deissenbock and Pizka, ’05], [Lawrie et al., ’07], [Abebe et al., ’09]
Venera Arnaoudova                            3                                    CSMR’13
What does it do?
     • Consider method:
            public ??? setBreadth(Dimension target, int source){ ??? }



     • What is it’s return type?
     • What is it’s implementation?
Expecting:            public void setBreadth(Dimension target, int source){
                         target.setBreadth(source);
                      }

Receiving:        public Dimension setBreadth(Dimension target, int source) {
                     if (orientation == VERTICAL)
                        return new Dimension(source, (int)target.getHeight());
                     else return new Dimension((int)target.getWidth(), source);
                  }
  Venera Arnaoudova                       4                          CSMR’13
Does more than it says
     • Consider method:
            public ??? setBreadth(Dimension target, int source){ ??? }



     • What is it’s return type?
     • What is it’s implementation?
Expecting:            public void setBreadth(Dimension target, int source){
                         target.setBreadth(source);
                      }

Receiving:        public Dimension setBreadth(Dimension target, int source) {
                     if (orientation == VERTICAL)
                        return new Dimension(source, (int)target.getHeight());
                     else return new Dimension((int)target.getWidth(), source);
                  }
  Venera Arnaoudova                       4                          CSMR’13
What does it do?
     Consider method:
     public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }


     • What is it’s return type?
     • What is it’s implementation?
Expecting:        public boolean isClassPathCorrect(..){
                     if(..){return true; else {return false;}
                  }

Receiving:        public void isClassPathCorrect(wellKnownType, compUnitDecl) {
                     referenceContext = compUnitDecl;
                     this.handle(..);
                  }

  Venera Arnaoudova                   5                           CSMR’13
Says more than it does
     Consider method:
     public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }


     • What is it’s return type?
     • What is it’s implementation?
Expecting:        public boolean isClassPathCorrect(..){
                     if(..){return true; else {return false;}
                  }

Receiving:        public void isClassPathCorrect(wellKnownType, compUnitDecl) {
                     referenceContext = compUnitDecl;
                     this.handle(..);
                  }

  Venera Arnaoudova                   5                           CSMR’13
What does it contain?
     • Consider attribute:
            private static ??? stats



     • What is it’s declared type?
     • What is it’s purpose?
Expecting:            private static int[] stats // some statistics..



Receiving:            private static boolean stats = true;




  Venera Arnaoudova                       6                             CSMR’13
Says more than it contains
     • Consider attribute:
            private static ??? stats



     • What is it’s declared type?
     • What is it’s purpose?
Expecting:            private static int[] stats // some statistics..



Receiving:            private static boolean stats = true;




  Venera Arnaoudova                       6                             CSMR’13
Linguistic Anti-Patterns

   • LAs: Recurring poor practices in the
        naming, documentation and choice of
        identifiers in the implementation.
   • Different families
    • One such family is related to
           inconsistencies:


Venera Arnaoudova             7               CSMR’13
Inconsistency LAs

   • Inconsistency between a program entity’s
    • documentation (i.e., comments)
    • name
    • behaviour (type, implementation)

Venera Arnaoudova       8                 CSMR’13
Inconsistency LAs          Others trust what you say!
 Behaviour
Does more than it says                Dimension setBreadth(..)


Says more than it does                void isClassPathCorrect(..)


Does the opposite than it says        ControlEnableState disable(..)



  State
Contains more than it says              int[] isReached


Says more than it contains              boolean _stats

                                       //.. default exclude pattern..
Contains the opposite than it says     INCLUDE_NAME_DEFAULT

   Venera Arnaoudova             9                        CSMR’13
Inconsistency LAs        Others trust what you say!

Behaviour

Does more than it says            “Set” method returns

                                  “Get” - more than an accessor

                                  “Is” returns more than a Boolean

                                  Expecting but not getting a single instance


 Says more than it does

  Does the opposite



 Venera Arnaoudova          10                                CSMR’13
Inconsistency LAs        Others trust what you say!

Behaviour

Does more than it says


Says more than it does            Not implemented condition

                                  Validation method does not confirm

                                  “Get” method does not return

                                  Not answered question

                                  Transform method does not return

                                  Expecting but not getting a collection
 Does the opposite

 Venera Arnaoudova          11                                 CSMR’13
Inconsistency LAs        Others trust what you say!

Behaviour


Does more than it says



 Says more than it does



 Does the opposite           Method name and return type are opposite

                             Method signature and comment are opposite


 Venera Arnaoudova          12                             CSMR’13
Inconsistency LAs         Others trust what you say!

  State

Contains more than it says          Says one but contains many

                                    Name suggests Boolean but type does not



Says more than it contains          Says many but contains one




Contains the opposite             Attribute name and type are opposite

                                  Attribute signature and comment are opposite




 Venera Arnaoudova           13                                  CSMR’13
Study

   • Prototype detector: LAPD
   • RQ: To what extent LAs exist?
   • Context:        System   Version
                               0.10.1
                                        Methods Attributes
                                             5K        3K
                    ArgoUML
                                0.34        11 K       6K
                    Cocoon     2.2.0         4K        3K
                    Eclipse      1.0        36 K      22 K


Venera Arnaoudova             14                             CSMR’13
Inconsistency LAs               Do they exist?
Behaviour                                  Detected
                                                       wrt the
                                                      population

      Does more than it says                194        0.35%
      Says more than it does               1016        1.82%
       Does the opposite than it says       288        0.52%

                                                       wrt the
State                                      Detected
                                                      population

       Contains more than it says           438        1.3%
       Says more than it contains           302        0.89%

    Contains the opposite than it says       24        0.07%

 Venera Arnaoudova             15                     CSMR’13
Inconsistency LAs                Confidence: 95% ±10%


Behaviour                                 Precision
      Does more than it says                 88%
      Says more than it does                 85%
       Does the opposite than it says        12%

State                                     Precision
       Contains more than it says            57%
       Says more than it contains            75%

    Contains the opposite than it says       13%
 Venera Arnaoudova             16                   CSMR’13
To summarize

   • Defined Inconsistency LAs
   • Prototype detection tool - LAPD
    • 72% precision
    • Inconsistency LAs represent 5% of the
           studied systems


Venera Arnaoudova            17          CSMR’13
Why do we care?

   • What can go wrong with LAs:
    • Useless time and effort spent to
           understand source code
       • Wrong assumptions
   • Being aware they exist is the first step...

Venera Arnaoudova         18                  CSMR’13
The next step
   • Opinion of developers
   • Study the impact
   • Solutions



Venera Arnaoudova         19        CSMR’13
Inconsistency LAs             What do you think?
 Behaviour
Does more than it says                void getMethodBodies(..)


Says more than it does                int isValid()


Does the opposite than it says        ControlEnableState disable(..)



  State
Contains more than it says              int[] isReached


Says more than it contains              boolean _stats

                                       //.. default exclude pattern..
Contains the opposite than it says     INCLUDE_NAME_DEFAULT

   Venera Arnaoudova             20                       CSMR’13

More Related Content

Viewers also liked

Increase pinterest followers software
Increase pinterest followers softwareIncrease pinterest followers software
Increase pinterest followers software
simon220
 
Increase number of followers on pinterest
Increase number of followers on pinterestIncrease number of followers on pinterest
Increase number of followers on pinterest
simon220
 
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
CTA Australia
 
Increase my pinterest followers
Increase my pinterest followersIncrease my pinterest followers
Increase my pinterest followers
simon220
 
Increase followers on pinterest
Increase followers on pinterestIncrease followers on pinterest
Increase followers on pinterest
simon220
 
How to more followers on pinterest
How to more followers on pinterestHow to more followers on pinterest
How to more followers on pinterest
simon220
 
Increasing your pinterest followers
Increasing your pinterest followersIncreasing your pinterest followers
Increasing your pinterest followers
simon220
 
Increasing pinterest followers
Increasing pinterest followersIncreasing pinterest followers
Increasing pinterest followers
simon220
 

Viewers also liked (13)

CSMR10c.ppt
CSMR10c.pptCSMR10c.ppt
CSMR10c.ppt
 
Increase pinterest followers software
Increase pinterest followers softwareIncrease pinterest followers software
Increase pinterest followers software
 
Increase number of followers on pinterest
Increase number of followers on pinterestIncrease number of followers on pinterest
Increase number of followers on pinterest
 
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
Ppt module 7 empowering & supporting the rights of yp v 7.12.2012
 
Automatizzare il percorso verso il cloud
Automatizzare il percorso verso il cloudAutomatizzare il percorso verso il cloud
Automatizzare il percorso verso il cloud
 
Increase my pinterest followers
Increase my pinterest followersIncrease my pinterest followers
Increase my pinterest followers
 
ICSOC12.ppt
ICSOC12.pptICSOC12.ppt
ICSOC12.ppt
 
Increase followers on pinterest
Increase followers on pinterestIncrease followers on pinterest
Increase followers on pinterest
 
VIMANTRA PHP SDK Introduction
VIMANTRA PHP  SDK IntroductionVIMANTRA PHP  SDK Introduction
VIMANTRA PHP SDK Introduction
 
How to more followers on pinterest
How to more followers on pinterestHow to more followers on pinterest
How to more followers on pinterest
 
Increasing your pinterest followers
Increasing your pinterest followersIncreasing your pinterest followers
Increasing your pinterest followers
 
Increasing pinterest followers
Increasing pinterest followersIncreasing pinterest followers
Increasing pinterest followers
 
130419 aminata sabane - a study of the impact of antipatterns on class test...
130419   aminata sabane - a study of the impact of antipatterns on class test...130419   aminata sabane - a study of the impact of antipatterns on class test...
130419 aminata sabane - a study of the impact of antipatterns on class test...
 

More from Ptidej Team

More from Ptidej Team (20)

From IoT to Software Miniaturisation
From IoT to Software MiniaturisationFrom IoT to Software Miniaturisation
From IoT to Software Miniaturisation
 
Presentation
PresentationPresentation
Presentation
 
Presentation
PresentationPresentation
Presentation
 
Presentation
PresentationPresentation
Presentation
 
Presentation by Lionel Briand
Presentation by Lionel BriandPresentation by Lionel Briand
Presentation by Lionel Briand
 
Manel Abdellatif
Manel AbdellatifManel Abdellatif
Manel Abdellatif
 
Azadeh Kermansaravi
Azadeh KermansaraviAzadeh Kermansaravi
Azadeh Kermansaravi
 
Mouna Abidi
Mouna AbidiMouna Abidi
Mouna Abidi
 
CSED - Manel Grichi
CSED - Manel GrichiCSED - Manel Grichi
CSED - Manel Grichi
 
Cristiano Politowski
Cristiano PolitowskiCristiano Politowski
Cristiano Politowski
 
Will io t trigger the next software crisis
Will io t trigger the next software crisisWill io t trigger the next software crisis
Will io t trigger the next software crisis
 
MIPA
MIPAMIPA
MIPA
 
Thesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.pptThesis+of+laleh+eshkevari.ppt
Thesis+of+laleh+eshkevari.ppt
 
Thesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.pptThesis+of+nesrine+abdelkafi.ppt
Thesis+of+nesrine+abdelkafi.ppt
 
Medicine15.ppt
Medicine15.pptMedicine15.ppt
Medicine15.ppt
 
Qrs17b.ppt
Qrs17b.pptQrs17b.ppt
Qrs17b.ppt
 
Icpc11c.ppt
Icpc11c.pptIcpc11c.ppt
Icpc11c.ppt
 
Icsme16.ppt
Icsme16.pptIcsme16.ppt
Icsme16.ppt
 
Msr17a.ppt
Msr17a.pptMsr17a.ppt
Msr17a.ppt
 
Icsoc15.ppt
Icsoc15.pptIcsoc15.ppt
Icsoc15.ppt
 

CSMR13d.ppt

  • 1. A New Family of Software Anti-Patterns: Linguistic Anti-Patterns Venera Arnaoudova1, Massimiliano Di Penta2, Giuliano Antoniol1,Yann-Gaël Guéhéneuc1 1 ÉcolePolytechnique de Montréal, Canada 2 University of Sannio, Benevento, Italy 1 CSMR’13
  • 2. Families of Patterns/Anti-Patterns • Patterns, e.g., Design • Anti-Patterns, e.g., Software Development Venera Arnaoudova 2 CSMR’13
  • 3. Source code lexicon i.e. vocabulary of your code • What do we know? • We should strive for good quality lexicon • How is quality of the lexicon measured? • English words, domain terms • Abbreviations, acronyms [Takang et al., ’96], [Deissenbock and Pizka, ’05], [Lawrie et al., ’07], [Abebe et al., ’09] Venera Arnaoudova 3 CSMR’13
  • 4. What does it do? • Consider method: public ??? setBreadth(Dimension target, int source){ ??? } • What is it’s return type? • What is it’s implementation? Expecting: public void setBreadth(Dimension target, int source){ target.setBreadth(source); } Receiving: public Dimension setBreadth(Dimension target, int source) { if (orientation == VERTICAL) return new Dimension(source, (int)target.getHeight()); else return new Dimension((int)target.getWidth(), source); } Venera Arnaoudova 4 CSMR’13
  • 5. Does more than it says • Consider method: public ??? setBreadth(Dimension target, int source){ ??? } • What is it’s return type? • What is it’s implementation? Expecting: public void setBreadth(Dimension target, int source){ target.setBreadth(source); } Receiving: public Dimension setBreadth(Dimension target, int source) { if (orientation == VERTICAL) return new Dimension(source, (int)target.getHeight()); else return new Dimension((int)target.getWidth(), source); } Venera Arnaoudova 4 CSMR’13
  • 6. What does it do? Consider method: public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? } • What is it’s return type? • What is it’s implementation? Expecting: public boolean isClassPathCorrect(..){ if(..){return true; else {return false;} } Receiving: public void isClassPathCorrect(wellKnownType, compUnitDecl) { referenceContext = compUnitDecl; this.handle(..); } Venera Arnaoudova 5 CSMR’13
  • 7. Says more than it does Consider method: public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? } • What is it’s return type? • What is it’s implementation? Expecting: public boolean isClassPathCorrect(..){ if(..){return true; else {return false;} } Receiving: public void isClassPathCorrect(wellKnownType, compUnitDecl) { referenceContext = compUnitDecl; this.handle(..); } Venera Arnaoudova 5 CSMR’13
  • 8. What does it contain? • Consider attribute: private static ??? stats • What is it’s declared type? • What is it’s purpose? Expecting: private static int[] stats // some statistics.. Receiving: private static boolean stats = true; Venera Arnaoudova 6 CSMR’13
  • 9. Says more than it contains • Consider attribute: private static ??? stats • What is it’s declared type? • What is it’s purpose? Expecting: private static int[] stats // some statistics.. Receiving: private static boolean stats = true; Venera Arnaoudova 6 CSMR’13
  • 10. Linguistic Anti-Patterns • LAs: Recurring poor practices in the naming, documentation and choice of identifiers in the implementation. • Different families • One such family is related to inconsistencies: Venera Arnaoudova 7 CSMR’13
  • 11. Inconsistency LAs • Inconsistency between a program entity’s • documentation (i.e., comments) • name • behaviour (type, implementation) Venera Arnaoudova 8 CSMR’13
  • 12. Inconsistency LAs Others trust what you say! Behaviour Does more than it says Dimension setBreadth(..) Says more than it does void isClassPathCorrect(..) Does the opposite than it says ControlEnableState disable(..) State Contains more than it says int[] isReached Says more than it contains boolean _stats //.. default exclude pattern.. Contains the opposite than it says INCLUDE_NAME_DEFAULT Venera Arnaoudova 9 CSMR’13
  • 13. Inconsistency LAs Others trust what you say! Behaviour Does more than it says “Set” method returns “Get” - more than an accessor “Is” returns more than a Boolean Expecting but not getting a single instance Says more than it does Does the opposite Venera Arnaoudova 10 CSMR’13
  • 14. Inconsistency LAs Others trust what you say! Behaviour Does more than it says Says more than it does Not implemented condition Validation method does not confirm “Get” method does not return Not answered question Transform method does not return Expecting but not getting a collection Does the opposite Venera Arnaoudova 11 CSMR’13
  • 15. Inconsistency LAs Others trust what you say! Behaviour Does more than it says Says more than it does Does the opposite Method name and return type are opposite Method signature and comment are opposite Venera Arnaoudova 12 CSMR’13
  • 16. Inconsistency LAs Others trust what you say! State Contains more than it says Says one but contains many Name suggests Boolean but type does not Says more than it contains Says many but contains one Contains the opposite Attribute name and type are opposite Attribute signature and comment are opposite Venera Arnaoudova 13 CSMR’13
  • 17. Study • Prototype detector: LAPD • RQ: To what extent LAs exist? • Context: System Version 0.10.1 Methods Attributes 5K 3K ArgoUML 0.34 11 K 6K Cocoon 2.2.0 4K 3K Eclipse 1.0 36 K 22 K Venera Arnaoudova 14 CSMR’13
  • 18. Inconsistency LAs Do they exist? Behaviour Detected wrt the population Does more than it says 194 0.35% Says more than it does 1016 1.82% Does the opposite than it says 288 0.52% wrt the State Detected population Contains more than it says 438 1.3% Says more than it contains 302 0.89% Contains the opposite than it says 24 0.07% Venera Arnaoudova 15 CSMR’13
  • 19. Inconsistency LAs Confidence: 95% ±10% Behaviour Precision Does more than it says 88% Says more than it does 85% Does the opposite than it says 12% State Precision Contains more than it says 57% Says more than it contains 75% Contains the opposite than it says 13% Venera Arnaoudova 16 CSMR’13
  • 20. To summarize • Defined Inconsistency LAs • Prototype detection tool - LAPD • 72% precision • Inconsistency LAs represent 5% of the studied systems Venera Arnaoudova 17 CSMR’13
  • 21. Why do we care? • What can go wrong with LAs: • Useless time and effort spent to understand source code • Wrong assumptions • Being aware they exist is the first step... Venera Arnaoudova 18 CSMR’13
  • 22. The next step • Opinion of developers • Study the impact • Solutions Venera Arnaoudova 19 CSMR’13
  • 23. Inconsistency LAs What do you think? Behaviour Does more than it says void getMethodBodies(..) Says more than it does int isValid() Does the opposite than it says ControlEnableState disable(..) State Contains more than it says int[] isReached Says more than it contains boolean _stats //.. default exclude pattern.. Contains the opposite than it says INCLUDE_NAME_DEFAULT Venera Arnaoudova 20 CSMR’13