130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns
TRANSCRIPT
![Page 1: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/1.jpg)
A New Family of Software Anti-Patterns: Linguistic Anti-Patterns
Venera Arnaoudova1, Massimiliano Di Penta2, Giuliano Antoniol1, Yann-Gaël Guéhéneuc1
1 École Polytechnique de Montréal, Canada2 University of Sannio, Benevento, Italy
1
![Page 2: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/2.jpg)
Families ofPatterns/Anti-Patterns• Patterns, e.g., Design
• Anti-Patterns, e.g., Software Development
2
![Page 3: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/3.jpg)
Source code lexicon
• What do we know?
• We should strive for good quality lexicon
• How is quality of the lexicon measured?
• English words, domain terms
• Abbreviations, acronyms
i.e. vocabulary of your code
3
[Takang et al., ’96], [Deissenbock and Pizka, ’05], [Lawrie et al., ’07], [Abebe et al., ’09]
![Page 4: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/4.jpg)
What does it do?
4
![Page 5: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/5.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
What does it do?
4
![Page 6: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/6.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
• What is it’s return type?
What does it do?
4
![Page 7: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/7.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
• What is it’s return type?
• What is it’s implementation?
What does it do?
4
![Page 8: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/8.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
• What is it’s return type?
• What is it’s implementation?
What does it do?
public void setBreadth(Dimension target, int source){ target.setBreadth(source); }
Expecting:
4
![Page 9: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/9.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
• What is it’s return type?
• What is it’s implementation?
What does it do?
public void setBreadth(Dimension target, int source){ target.setBreadth(source); }
Expecting:
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); }
4
![Page 10: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/10.jpg)
• Consider method: public ??? setBreadth(Dimension target, int source){ ??? }
• What is it’s return type?
• What is it’s implementation?
public void setBreadth(Dimension target, int source){ target.setBreadth(source); }
Expecting:
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); }
4
Does more than it says
![Page 11: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/11.jpg)
What does it do?
5
![Page 12: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/12.jpg)
What does it do?Consider method:
5
![Page 13: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/13.jpg)
What does it do?Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
5
![Page 14: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/14.jpg)
What does it do?Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
• What is it’s return type?
5
![Page 15: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/15.jpg)
What does it do?Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
• What is it’s return type?
• What is it’s implementation?
5
![Page 16: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/16.jpg)
What does it do?Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
• What is it’s return type?
• What is it’s implementation?
public boolean isClassPathCorrect(..){ if(..){return true; else {return false;}}
Expecting:
5
![Page 17: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/17.jpg)
What does it do?Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
• What is it’s return type?
• What is it’s implementation?
public boolean isClassPathCorrect(..){ if(..){return true; else {return false;}}
Expecting:
Receiving: public void isClassPathCorrect(wellKnownType, compUnitDecl) { referenceContext = compUnitDecl; this.handle(..); }
5
![Page 18: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/18.jpg)
Consider method:public ??? isClassPathCorrect(wellKnownType, compUnitDecl){ ??? }
• What is it’s return type?
• What is it’s implementation?
public boolean isClassPathCorrect(..){ if(..){return true; else {return false;}}
Expecting:
Receiving: public void isClassPathCorrect(wellKnownType, compUnitDecl) { referenceContext = compUnitDecl; this.handle(..); }
5
Says more than it does
![Page 19: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/19.jpg)
What does it contain?
6
![Page 20: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/20.jpg)
What does it contain?
• Consider attribute: private static ??? stats
6
![Page 21: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/21.jpg)
What does it contain?
• Consider attribute: private static ??? stats
• What is it’s declared type?
6
![Page 22: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/22.jpg)
What does it contain?
• Consider attribute: private static ??? stats
• What is it’s declared type?
• What is it’s purpose?
6
![Page 23: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/23.jpg)
What does it contain?
• Consider attribute: private static ??? stats
• What is it’s declared type?
• What is it’s purpose?
private static int[] stats // some statistics..Expecting:
6
![Page 24: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/24.jpg)
What does it contain?
• Consider attribute: private static ??? stats
• What is it’s declared type?
• What is it’s purpose?
private static int[] stats // some statistics..Expecting:
Receiving: private static boolean stats = true;
6
![Page 25: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/25.jpg)
• Consider attribute: private static ??? stats
• What is it’s declared type?
• What is it’s purpose?
private static int[] stats // some statistics..Expecting:
Receiving: private static boolean stats = true;
6
Says more than it contains
![Page 26: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/26.jpg)
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:
7
![Page 27: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/27.jpg)
• Inconsistency between a program entity’s
• documentation (i.e., comments)
• name
• behaviour (type, implementation)
8
Inconsistency LAs
![Page 28: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/28.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
9
Dimension setBreadth(..)
void isClassPathCorrect(..)
boolean _stats
Others trust what you say!
![Page 29: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/29.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
9
Dimension setBreadth(..)
void isClassPathCorrect(..)
ControlEnableState disable(..)
boolean _stats
Others trust what you say!
![Page 30: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/30.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
9
Dimension setBreadth(..)
void isClassPathCorrect(..)
ControlEnableState disable(..)
int[] isReached
boolean _stats
Others trust what you say!
![Page 31: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/31.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
9
Dimension setBreadth(..)
void isClassPathCorrect(..)
ControlEnableState disable(..)
int[] isReached
boolean _stats
//.. default exclude pattern..INCLUDE_NAME_DEFAULT
Others trust what you say!
![Page 32: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/32.jpg)
Does more than it says
Says more than it does
Does the opposite
Behaviour
“Get” - more than an accessor
“Is” returns more than a Boolean
“Set” method returns
Expecting but not getting a single instance
Inconsistency LAs
10
Others trust what you say!
![Page 33: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/33.jpg)
Does more than it says
Says more than it does
Does the opposite
Validation method does not confirm
“Get” method does not return
Not implemented condition
Not answered question
Transform method does not return
Expecting but not getting a collection
Behaviour
Inconsistency LAs
11
Others trust what you say!
![Page 34: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/34.jpg)
Does more than it says
Says more than it does
Does the oppositeMethod signature and comment are opposite
Method name and return type are opposite
Behaviour
Inconsistency LAs
12
Others trust what you say!
![Page 35: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/35.jpg)
Contains more than it says
Says more than it contains
Name suggests Boolean but type does not
Says one but contains many
Says many but contains one
Attribute signature and comment are opposite
Attribute name and type are opposite
Inconsistency LAs
State
13
Others trust what you say!
Contains the opposite
![Page 36: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/36.jpg)
Study
• Prototype detector: LAPD
• RQ: To what extent LAs exist?
• Context: System Version Methods Attributes
ArgoUML0.10.1 5 K 3 K
ArgoUML0.34 11 K 6 K
Cocoon 2.2.0 4 K 3 KEclipse 1.0 36 K 22 K
14
![Page 37: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/37.jpg)
Inconsistency LAs
Does more than it says
Do they exist?
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
Detectedwrt the
population
194 0.35%
1016 1.82%
288 0.52%
Detectedwrt the
population
438 1.3%
302 0.89%
24 0.07%
15
![Page 38: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/38.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
Precision
88%
85%
12%
Precision
57%
75%
13%
16
Confidence: 95% ±10%
![Page 39: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/39.jpg)
To summarize
• Defined Inconsistency LAs
• Prototype detection tool - LAPD
• 72% precision
• Inconsistency LAs represent 5% of the studied systems
17
![Page 40: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/40.jpg)
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...
18
![Page 41: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/41.jpg)
The next step
• Opinion of developers
• Study the impact
• Solutions
19
![Page 42: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/42.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
20
void getMethodBodies(..)
int isValid()
ControlEnableState disable(..)
int[] isReached
boolean _stats
//.. default exclude pattern..INCLUDE_NAME_DEFAULT
![Page 43: 130102 venera arnaoudova - a new family of software anti-patterns linguistic anti-patterns](https://reader031.vdocuments.site/reader031/viewer/2022030318/5a6e6a787f8b9a1f288b5b4d/html5/thumbnails/43.jpg)
Inconsistency LAs
Does more than it says
Says more than it does
Does the opposite than it says
Contains more than it says
Says more than it contains
Contains the opposite than it says
Behaviour
State
20
void getMethodBodies(..)
int isValid()
ControlEnableState disable(..)
int[] isReached
boolean _stats
//.. default exclude pattern..INCLUDE_NAME_DEFAULT
What do you think?