Understanding mobile-specific code smells Presented by: Sarra Habchi Advisor: Examiners: - Romain Rouvoy - Jean-Christophe Routier Rapporteurs: - Naouel Moha - Andy Zaidman - Tegawendé-François Bissyande - Yann-Gaël Guéhéneuc
2 Raconteur.net
3
4
5
6
7
8
Performance matters! 9
Performance practices matter! 10
Performance bad practices 11
Performance bad practices ● Resource leaks (Guo et al. 2013) ● 3 anti-patterns (Liu et al. 2014) ● 30 code smells (Reimann et al. 2014) → Mobile-specific code smells 12
Mobile-specific code smells ● Catalog ● Reused & extended in later studies ● 14 studies 13
Official documentation Catalog of 30 Developer Android code smells Semi-automated blogs & talks ... analysis performance Q&A forums 14
UI Overdraw 15
1 overdraw 2 overdraws 3 overdraws 4 overdraws 16
Detection tools 17
Detection tools ● Paprika (Hecht et al. 2015) ● aDoctor (Palomba et al. 2017) ● MOGP approach (Kessentini and Ouni 2017) 18
Impact on performance 19
Impact on performance ● UI & Memory (Hecht et al. 2016) ● Energy (Carette et al. 2017) ● Energy (Palomba et al. 2019) 20
Code smell Detection Impact on catalog tools performance ? 21
22
Causes Relevance Adequate tools 23
We have: Code smell Detection Impact on catalog tools performance We lack: Understand Refactoring Refactoring code smells catalog tools 24
1. Extent 2. Causes 3. Developers’ perception Understanding mobile code smells 25
1. Extent 2. Causes 3. Developers’ perception Understanding mobile code smells 26
27
Code Smells in iOS Apps: How do they compare to Android? ● Identified 6 iOS-specific code smells ● Common code smells between Android and iOS ● Proposed a detection tool for iOS ● Android apps tend to have more smells than the iOS ones 28
1. Extent 2. Causes 3. Developers’ perception Understanding mobile code smells 29
1. Extent 2. Causes 3. Developers’ perception Understanding mobile code smells 30
Motives of technical debt (Tom et al. 2013) Pragmatism Prioritisation Process Attitudes Ignorance Oversight 31
Motives of technical debt (Tom et al. 2013) Pragmatism Prioritisation Process Attitudes Ignorance Oversight 32
Motives of technical debt (Tom et al. 2013) Pragmatism Prioritisation Process Attitudes Ignorance Oversight 33
34
1- Commits 2- Developers 3- Survival 35
1- Commits 2- Developers 3- Survival 36
Code smell Code smell removal introduction ... ... Commit 0 Commit 1 Commit k Commit n Instance A Instance A Instance A Instance A Instance B Instance B 37
Instance A Instance A Instance C ... Commit p Commit m ... ... Commit 0 Commit 1 Commit k Commit n Instance A Instance A Instance A Instance A Instance B Instance B 38
RegistrationSocket.java GcmSocket.java Commit 303d1ac : File renaming link Instance Instance RegistrationSocket$Verification GcmSocket$Verification 39
Branches + Renamings 40
41
Sniffer Git link to 1 -Extract app 2 - Detect 3 - Analyse Instances Commits an app data code smells change history Full code Repository smell history model 42
Sniffer ● Track branches ● Detect renamings ● Validated with: ○ F1-score=0.96 43
Dataset ● 324 open-source apps ● 255,000 commits ● 4,525 developers 44
LIC Leaking Inner Class MIM Member Ignoring Method NLMR No Low Memory Resolver HMU HashMap Usage UIO UI Overdraw UHA Unsupported Hardware Acceleration IOD Init OnDraw UCS Unsuited Cache Size 45
Introductions 46
% Removals 47
79% of code smell instances are removed 48
Intended removal? 49
No Low Memory Resolver 50
51
52
Source code deletion 53
% Removals by deletion 54
59% of code smell removals are accompanied with source code deletion 55
Manual analysis ● 561 code smell instances ○ Commit actions ○ Commit message 56
How are code smells removed? ● Removal is a side effect of evolution ○ Source code deleted ○ Empty methods filled (MIM) 57
How are code smells removed? ● Only refactoring: ○ Code smells detected by Android Lint ■ Init OnDraw (IOD) ■ UI Overdraw (UIO) 58
Most of code smell removals are a side-effect of other activities 59
Motives of technical debt Pragmatism Prioritisation Process Attitudes Ignorance Oversight 60
How do releases impact code smell introductions and removals? 61
1 Day 1 Week 1 Month 62
Releases do not have any impact on code smell introductions or removals. 63
Motives of technical debt Pragmatism Prioritisation Process Attitudes Ignorance Oversight 64
1- Commits 2- Developers 3- Survival 65
1- Commits 2- Developers 3- Survival 66
67
Who is involved? 68
69
Mainly 38% 1 commit 70
Involved developers 71
Introducers Removers 72
Introducers 18% 73
Introducers BOTH Removers 18% 8% 74
Expected Removals Introductions 75
⍴ = 0.77 76
Introducers ≃ Removers 77
Seniority and code smells ● Contribution = commits/project size ● Reputation ≃ followers “Developers with lots of followers were treated as local celebrities. Their activities were retold almost as local parable” 78 (Dabbish et al. 2012)
⍴ = 0.27 ⍴ = 0.24 79
Junior Senior Junior Senior → Seniority does not impact developers’ behavior 80
● Introducers ⋍ Removers ● Newcomer ⟹ Bad contributor ● Senior || Reputable ⟹ Good contributor 81
Motives of technical debt Pragmatism Prioritisation Process Attitudes Ignorance Oversight 82 82
1- Commits 2- Developers 3- Survival 83
1- Commits 2- Developers 3- Survival 84
85
Survival analysis ● S(t) = Probability(t < T) ● T: a random lifetime from the population “Chances for a code smell to be still present in the source code after t time” ● 180.000 code smell lifelines 86
441 days 14 months 87
9 commits 88
14 months vs. 9 effective commits 89
Variables: project properties ● Project size ○ #Classes ○ #Commits ○ #Developers ● Project releases ○ #Releases ○ Cycle 90
Variables: Code smell properties ● Tool integration ○ Linted (detectable by Android Lint) ○ Linter priority ● Code smell type ○ Granularity 91
Variables: Code smell properties ● Tool integration ○ Linted (detectable by Android Lint) ○ Linter priority ● Code smell type ○ Granularity 92
→ Static analysers have an impact on mobile code smells → Tool prioritisation matters 93
94
Motives of technical debt Pragmatism Prioritisation Process Attitudes Ignorance Oversight 95 95
1. Extent 2. Causes: - Change history 3. Developers’ perception Understanding mobile code smells 96
1. Extent 2. Causes: - Change history 3. Developers’ perception Understanding mobile code smells 97
98
Catalog of performance code smells How do they use the linter to deal with performance concerns? 99
Semi-structured Experienced Interviews Android developers Analytical strategy Qualitative approach of (Schmidt et al. 2004) 100 100
Recommend
More recommend