SlideShare a Scribd company logo
Department of Computer Science and Operations Research
A mono- and Multi-objective Approach for
Recommending Software Refactoring
Ali Ouni
Ph.D. Defense
Advisors: Houari Sahraoui (Université de Montréal, Canada)
Marouane Kessentini (University of Michigan, USA)
12 November 2014
Outline
 Context and problem
 Research methodology
 Code-smells detection
 Mono-objective software refactoring
 Multi-objective software refactoring
 Conclusion and perspectives
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 2
Context
 Software systems have become prevalent in our everyday life
 Software changes frequently
 Add new requirements
 Adapt to environment changes
 Correct bugs
 Changing a software can be a challenging task
 These changes may degrade their design and QoS
 The original developers are not around anymore
 Easiness to accommodate changes depends on software quality
 Maintain a high level of quality during the life cycle of a software system
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring Univ. de Montréal, Nov. 12th, 2014 3
Refactoring
 “ The process of improving a code after it has been written by
changing its internal structure without changing the external behavior ”
(Fowler et al., ‘99)
 Examples: Move method, extract class, move attribute, ...
 Eclipse, NetBeans, …
 Advantages
 Improve software quality, maintainability, readability
 Provide better software extensibility
 Increase the speed at which programmers can write and maintain their code
 Challenges…
 Manual refactoring is an error-prone task
 What are the situations ? What are the refactorings to apply?
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 4
Refactoring
 Need for recommendation systems
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 5
Identification of
refactoring solutions
Guarantee behavior
preservation
Apply refactoring
Assess the effect of the
refactoring on quality
Maintain the consistency
with other artifacts
(e.g., documentation, ..)
Detection of code
fragments to improve
(e.g., code-smells)
Step 1: Code-smells detection
 Code-smells
 Introduced during the initial design or during evolution
 Anomalies, anti-patterns, bad smells, design flaws, …
 “ Metaphor ” to describe problems resulting from bad design and
programming practices
 Time pressure, non-experienced programmers, unintentionally, code decay
 Lead to software products suffering by poor performance and QoS
 Code difficult to understand, modify, maintain, evolve ...
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 6
Code smells
What is that smell? Did you write that code?
Code-smell examples
 Blob
“Procedural-style design leads to one object with
numerous responsibilities and most other objects only
holding data or executing simple processes”
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 7
 Spaghetti code
“It is a code with a complex and tangled control structure.
This code-smell is characteristic of procedural thinking in
object-oriented programming. Spaghetti Code is revealed
by classes with no structure, declaring long methods with
no parameters, and utilising global variables” Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-fine_Amount
-listOfCatalogs
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availabi_Book()
+check_Delay_Book()
+check_FineAmount()
+check_ValidityCard()
+close_Librairy()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
+print_Catalog()
+remove__Book()
+reserve_Book()
+return_Book()
+search_Book()
+search_Catalog()
+sort_Catalog()
Catalog
-…
+…()
Book
-…
+…()
Data Class
Data Class
Step 2: Refactoring
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 8
Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-fine_Amount
-listOfCatalogs
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availab_Book()
+check_Delay_Book()
+check_FineAmount()
+check_ValidityCard()
+close_Librairy()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
+print_Catalog()
+remove_Book()
+reserve_Book()
+return_Book()
+search_Book()
+search_Catalog()
+sort_Catalog()
Catalog
-…
+…()
Book
-…
+…()
Data Class
Data Class
Librairy_Main_Control
-current_Catalog
-listOfCatalogs
+sort_Catalog()
+add_Book()
+list_Catalogs()
+remove_Book()
+search_Book()
+search_Catalog()
Catalog
-current_Book
+archive_Catalog()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+print_Catalog()
Book
-borrow_date_Book
-return_date_Book
-reserved_Book
+return_Book()
+borrow_Book()
+check_Delay_Book()
+reserve_Book()
+check_Availabi_Book()
Data Class
NewClass_1
-fine_Amount
+chek_FineAmount()
+check_ValidityCard()
+issue_LibrairyCard()
NewClass_2
-librairy_opened
+close_Librairy()
+open_Librairy()
Data Class
Blob
Refactoring
Move method
Extract class
Move field
Inline class
…
Thesis
 Goal
“Automated approach for recommending software
refactoring”
 Generate code-smells detection rules
 Find refactoring solutions to fix code-smells while preserving the design
semantics
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 9
Research methodology
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 10
recommended
refactorings
Part 2
Mono-objective code-smells correction
Generation of
detection rules
(GP)
Mono-objective search-
based Refactoring
(GA / CRO)
detection
rules
Part 1
Code-smells detection
Quality metrics
Part 3
Multi-objective refactoring
Examples
of
code-smells
Multi-objective search-
based Refactoring
(NSGA-II)
Semantic
measures
Modification
score
Code-change
history
Design-pattern
detectors
recommended
refactorings
List of
refactoring
operations
 Context and problem
 Research methodology
 Code-smells detection
 Mono-objective software refactoring
 Multi-objective software refactoring
 Conclusion and perspectives
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 11
recommended
refactorings
Part 2
Mono-objective code-smells correction
Generation of
detection rules
(GP)
Mono-objective search-
based Refactoring
(GA / CRO)
detection
rules
Part 1
Code-smells detection
Quality metrics
Part 3
Multi-objective refactoring
Examples
of
code-smells
Multi-objective search-
based Refactoring
(NSGA-II)
Semantic
measures
Modification
score
Code-change
history
Design-pattern
detectors
recommended
refactorings
List of
refactoring
operations
Research methodology
Code-smells detection
 Existing work
 Manual (Brown et al. ‘98, Fowler and Beck ‘99)
 Metrics-based (Palomba et al ‘13, Marinescu et al. ’04, Salehie et al. ’06, Maiga
et al.‘12)
 Visual (Dhambri et al. ’08, Langelier et al. ’05)
 Symptoms-based (Moha et al. ’08, Murno et al. ‘08)
Definition  symptoms  detection algorithm
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 12
Problem statement
 Difficult to define/express detection rules
 Large list of code-smells to categorize
 Large exhaustive list of quality metrics
 Huge number of possible threshold values
 Huge space to explore: An expert to manually write and validate detection rules
 Difficult to derive consensual rules
 Diverge expert’s opinions
 No consensual definition of symptoms
 The same symptom could be associated to many code-smell types
 Easier to describe examples than translating symptoms into rules
Idea: Infer detection rules from code-smell examples
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 13
Approach overview
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 14
Part 1
Code-smells detection
Generation of
code-smells
detection rules
(Genetic Algorithm)
Software quality
metrics
(CBO, WMC,
NOA,…)
Code-smells
detection
rules
Examples of
code-smells
System 2System 1
System 3
Code-smell
instance
Genetic Programming
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 15
Population of
solutions
Evaluation
Selection
Crossover
Mutation
Optimal or
“good” solution
found ?
Detection rules
Yes
No
START
END
 Key elements
 Representing of individual
 Evaluating an individual
 Deriving new individuals using genetic
operators
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014
GP adaptation
WMC
LCOM
NOM
CBO
[1..500]
[1..100]
Quality metrics
NOA
 Solution representation
16
1 : Blob
2 : Spaghetti code
3 : Functional decomposition
Base of examples
Code-smell
instance
3 : If (NOA≥4) AND (WMC<3) Then Functional decomposition
2 : If (CBO≥ 151) Then Spaghetti code
1 : If (LOCCLASS≥1500) AND (NOM≥20) OR (WMC>20) Then Blob
R1: Blob
R2: SC
R3: FD
OR
OR AND
AND
LOCClASS
≥ 1500
NOM ≥ 20
CBO ≥ 151
NOA ≥ 4
CBO<3
MWC ≥
20
N6
N1
N2
N3
N4
N5 N7
N8
N10
N9
Tree representation
 Fitness function
𝑅𝑒𝑐𝑎𝑙𝑙 =
𝑡𝑟𝑢𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠
𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑐𝑜𝑑𝑒 𝑠𝑚𝑒𝑙𝑙𝑠
𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 =
𝑡𝑟𝑢𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠
𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑑𝑒𝑡𝑒𝑐𝑡𝑒𝑑 𝑐𝑜𝑑𝑒 𝑠𝑚𝑒𝑙𝑙𝑠
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 17
 Studied systems
 Three types of code-smells
 Blob, Spaghetti code, Functional decomposition
 6-fold cross validation
 Detect smells in a system using the 5 other systems
 Detection precision and recall
Evaluation: detection results
Systems # of classes KLOC # of code-smells
Quick UML v2001 142 19 11
LOG4J v1.2.1 189 21 17
GanttProject v1.10.2 245 31 41
Xerces-J v2.7.0 991 240 66
ArgoUML v0.19.8 1230 1160 89
AZUREUS v2.3.0.6 1449 42 93
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 18
Detection results
System Precision Recall
GanttProject
Blob : 100%
SC : 93%
FD : 91%
100%
97%
94%
Xerces-J
Blob : 97%
SC: 90%
FD: 88%
100%
88%
86%
ArgoUML
Blob : 93%
SC: 88%
FD: 82%
100%
91%
89%
QuickUML
Blob : 94%
SC: 84%
FD: 81%
98%
93%
88%
AZUREUS
Blob : 82%
SC: 71%
FD: 68%
94%
81%
86%
LOG4J
Blob : 87%
SC: 84%
FD: 66%
90%
84%
74%
Average
Blob : 92%
SC: 85%
FD: 79%
97%
89%
86%
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 19
Examples-size variation
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
1 2 3 4 5
Precision
Recall
Precision, recall %
Number of systems
Outline
 Context and problem
 Research methodology
 Code-smells detection
 Mono-objective software refactoring
 Multi-objective software refactoring
 Conclusion and perspectives
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 20
recommended
refactorings
Part 2
Mono-objective code-smells correction
Generation of
detection rules
(GP)
Mono-objective search-
based Refactoring
(GA / CRO)
detection
rules
Part 1
Code-smells detection
Quality metrics
Part 3
Multi-objective refactoring
Examples
of
code-smells
Multi-objective search-
based Refactoring
(NSGA-II)
Semantic
measures
Modification
score
Code-change
history
Design-pattern
detectors
recommended
refactorings
List of
refactoring
operations
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 21
 Manual approaches
– Standard refactorings (Fowler et al. ‘98)
 Metric-based approaches
– Search-based techniques
• Find the best sequence of refactorings (Seng et al. ‘06, Harman et al. ’07,
O’Keeffe et al. ’08,)
– Analytic approaches
• Study of relations between some quality metrics and refactoring
changes (Sahraoui et al. ’00, Du Bois et al. ’04, Moha et al. ’08)
 Clustering-based approaches
– Fix code-smells (Marios et al, ’11, JDeodorant)
Existing work on refactoring
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 22
 Difficult to define "standard" refactorings
 Pre-define refactoring solutions for each code-smell type
 Difficult to establish the link between refactoring and quality
improvement
 Improving some quality metrics do not fix code-smells
 Is not practical to correct code-smells separately
 Correcting a code-smell may produce other code-smells
 Do not consider the impact of refactoring
 Do not take into consideration the semantic coherence dimension
Problem statement
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 23
 Two scenarios
1. Enough time/resources
2. Time/resources limitations
Mono-objective Refactoring
recommended
refactorings
Part 2
Mono-objective code-smells correction
Basic Mono-objective
Refactoring
(GA)
Prioritizing code-smells
correction
(CRO)
List of
refactoring
operations
+
Detection rules
Scenario 1
Scenario 2recommended
refactorings
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 24
Basic mono-objective refactoring
Code to be
refactored
Suggested
refatorings
Code-smells
detection rules
List of possible
refactorings
Basic Code-smells
correction
(Genetic Algorithm)
Scenario 1
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 25
 Genetic Algorithm
 Solution representation
 Individual = Sequence of refactoring operations
 Controlling parameters
Genetic algorithm adaptation
Refactorings Controlling parameters
move method (sourceClass, targetClass, method)
move field (sourceClass, targetClass, field)
pull up field (sourceClass, targetClass, field)
pull up method (sourceClass, targetClass, method)
push down field (sourceClass, targetClass, field)
push down method (sourceClass, targetClass, method)
inline class (sourceClass, targetClass)
extract class (sourceClass, newClass)
1 moveMethod
2 pullUpAttribute
3 extractClass
4 inlineClass
5 extractSuperClass
6 inlineMethod
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 26
 Population creation
 Population: set of refactoring solutions
 Fitness function
Genetic algorithm adaptation
Correction ratio =
# code smells 𝑎𝑓𝑡𝑒𝑟 𝑟𝑒𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑛𝑔
# detected code smells
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
pullUpAttribute
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
inlineClass
inlineMethod
extractSuperClass
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
inlineClass
extractSuperClass
inlineMethod
extractClass
pullUpAttribute
extractClass
moveMethod
moveMethod
pullUpAttribute
extractClass
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 27
Evaluation: basic refactoring results
System CCR RP
GanttProject 95% (39|41) 52 %
Xerces-J 89% (59|66) 49 %
ArgoUML 85% (76|89) 59 %
QuickUML 90% (26|29) 59 %
LOG4J 88% (15|17) 51 %
AZUREUS 94% (87|93) 57 %
Average 90% 54%
𝐂𝐂𝐑 =
# 𝐜𝐨𝐝𝐞 𝐬𝐦𝐞𝐥𝐥𝐬 𝐚𝐟𝐭𝐞𝐫 𝐚𝐩𝐩𝐥𝐲𝐢𝐧𝐠 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬
# 𝐜𝐨𝐝𝐞 𝐬𝐦𝐞𝐥𝐥𝐬 𝐛𝐞𝐟𝐨𝐫𝐞 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠
𝐑𝐏 =
# 𝐦𝐞𝐚𝐧𝐢𝐧𝐠𝐟𝐮𝐥 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬
# 𝐩𝐫𝐨𝐩𝐨𝐬𝐞𝐝 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 28
Mono-objective Refactoring
recommended
refactorings
Part 2
Mono-objective code-smells correction
Basic Mono-objective
Refactoring
(GA)
Prioritizing code-smells
correction
(CRO)
List of
refactoring
operations
+
Detection rules
Scenario 1
Scenario 2recommended
refactorings
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 29
 Second scenario
 Time / resources limitations
 Don’t need to fix all code-smells -> only the most critical ones
 Idea: Prioritize the correction of code smells
Priority-based refactoring
Priority-based code-smells
correction
(Chemical reaction optimisation)Code to be
refactored
Suggested
refatorings
Code-smells
detection rules
List of possible
refactorings
Prioritisation
schema
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 30
 Four heuristics
 Priority
 rank code-smells according to the maintainers preferences
 Severity
 rank code-smells according to a set of design-properties (size, complexity, coupling,
cohesion, hierarchy, etc.)
 Risk
 the risk score corresponds to the deviation from good design practices.
 the more code deviates from good practices, the more it is likely to be risky
 Importance
 the importance of a class corresponds to their change frequency
 the more a class undergoes changes, the more it is likely to be problematic
 if a code-smell remains unmodified, the system may not experience problems
Prioritizing code-smells correction
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 31
 Goal:
 maximize the correction of the critical code-smells
 Objective function
 weighted sum of the prioritization heuristics
 Chemical reaction optimisation (CRO)
 Inspired by the phenomenon of chemical reactions
 Molecule <--> solution
 Potential energy <--> objective function value
 Collision <--> change operator (mechanism to find new solution)
Prioritizing code-smells correction
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 32
 Comparison
1. Our CRO-based approach
2. CRO without prioritization
3. Basic GA approach
Refactoring comparison results for the five systems from 31 simulation runs
Validation: CRO refactoring results
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 33
 Comparison
1. Chemical Reaction Optimization (CRO)
2. Genetic Algorithm (GA)
3. Simulated Annealing (SA)
4. Particle Swarm Optimisation (PSO)
Refactoring comparison results for the five systems from 31 simulation runs
SBSE validation
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 34
 Stability
Results
45
47
49
51
53
55
57
59
75
80
85
90
95
100
210
216
222
232
232
236
241
255
257
259
265
268
270
271
271
274
275
276
276
277
277
278
279
280
281
281
282
282
282
285
288
Number of refactorings
CCR (%) ICR (%) RCR (%) SCR (%) Time (min)
CCR (%), ICR(%), RCR(%) , SCR(%) Time (min)
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 35
Refactorings distribution
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 36
 Advantages
 Most of code-smells are fixed
 Critical code-smells are fixed first (prioritized)
 Limitations
 Not all suggested refactoring operations are semantically feasible
 Some refactoring solutions requires a considerable number of changes
 Single perspective ?
Mono-objective formulation
Outline
 Context and problem
 Research methodology
 Code-smells detection
 Mono-objective software refactoring
 Multi-objective software refactoring
 Conclusion and perspectives
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 37
recommended
refactorings
Part 2
Mono-objective code-smells correction
Generation of
detection rules
(GP)
Mono-objective search-
based Refactoring
(GA / CRO)
detection
rules
Part 1
Code-smells detection
Quality metrics
Part 3
Multi-objective refactoring
Examples
of
code-smells
Multi-objective search-
based Refactoring
(NSGA-II)
Semantic
measures
Modification
score
Code-change
history
Design-pattern
detectors
recommended
refactorings
List of
refactoring
operations
 Two intuitions
 Design preservation objectives
 Semantic approximation
 Number of changes
 Conformance with refactoring history
 Quality objectives
 Fix code-smells
 Improve quality indicators
 Introduce design patterns
 …
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 38
Multi-objective formulation
Multi-objective optimization problem
Application 1
Application 2
 NSGA-II: Non-dominated Sorting Genetic Algorithm (K. Deb et al., ’02)
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 39
NSGA-II overview
Parent
Population
Offspring
Population
Non-dominated
sorting
F1
F2
F3
F4
Crowding distance
sorting
Population
in next
generation
 Two intuitions
 Design preservation objectives
 Semantic approximation
 Number of changes
 Conformance with refactoring history
 Quality objectives
 Fix code-smells
 Improve quality indicators
 Introduce design patterns
 …
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 40
Multi-objective formulation
Multi-objective optimization problem
Application 1
Application 2
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 41
Application 1: Design preservation FIRST !
Refactoring
history
Proposed
refactorings
Semantic
measures
D
Multi-objective Refactoring
(NSGA-II)
Source code with
code-smells
Code-smells
detection rules
List of possible
refactorings
 Four objective functions
1. Quality
 Calculate the number of fixed code-smells
2. Code changes
 Calculate the number of atomic changes required when applying refactoring
3. Approximate semantic similarity
 Calculate cosine similarity between vocabulary used
4. Maintain the conformance with change history
 Calculate a similarity score between the a suggested refactoring and a base of refactorings applied in the
past
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 42
NSGA-II adaptation
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 43
 Number of code changes
Refactoring criteria. . .
Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-fine_Amount
-listOfCatalogs
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availab_Book()
+check_Delay_Book()
+check_FineAmount()
+check_ValidityCard()
+close_Librairy()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
+print_Catalog()
+remove_Book()
+reserve_Book()
+return_Book()
+search_Book()
+search_Catalog()
+sort_Catalog()
Catalog
-…
+…()
Book
-…
+…()
Data Class
Data Class
Librairy_Main_Control
-current_Catalog
-listOfCatalogs
+sort_Catalog()
+add_Book()
+list_Catalogs()
+remove_Book()
+search_Book()
+search_Catalog()
Catalog
-current_Book
+archive_Catalog()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+print_Catalog()
Book
-borrow_date_Book
-return_date_Book
-reserved_Book
+return_Book()
+borrow_Book()
+check_Delay_Book()
+reserve_Book()
+check_Availabi_Book()
Data Class
NewClass_1
-fine_Amount
+chek_FineAmount()
+check_ValidityCard()
+issue_LibrairyCard()
NewClass_2
-librairy_opened
+close_Librairy()
+open_Librairy()
Data Class
Blob
Refactoring
Solution 3
1. Move method
2. Extract class
3. Move field
4. Move method
5. Move method
6. Inline class
7. Move field
8. Extract class
9. Move method
10 Move field
Solution 1
1. Move method
2. Extract class
3. Move field
4. Move method
5. Move method
Solution 2
1. Move method.
2. Move method
3. Inline class
4. Move field
5. Extract class
Solution 4
1. Move method.
2. Move method
3. Inline class
4. Move field
5. Extract class
6. Move field
7. Extract class
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 44
 Semantic similarity
Refactoring criteria. . .
Catalog
-current_Book
+archive_Catalog()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+print_Catalog()
Book
-borrow_date_Book
-return_date_Book
-reserved_Book
+return_Book()
+borrow_Book()
+check_Delay_Book()
+reserve_Book()
+check_Availabi_Book()
NewClass_1
-fine_Amount
+chek_FineAmount()
+check_ValidityCard()
+issue_LibrairyCard()
NewClass_2
-librairy_opened
+close_Librairy()
+open_Librairy()
Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-fine_Amount
-listOfCatalogs
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availabi_Book()
+check_Delay_Book()
+check_FineAmount()
+check_ValidityCard()
+close_Librairy()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
+print_Catalog()
+remove__Book()
+reserve_Book()
+return_Book()
+search_Book()
+search_Catalog()
+sort_Catalog()
NewClass_1
-fine_Amount
+chek_FineAmount()
+check_ValidityCard()
+issue_LibrairyCard()
Code-smell: Blob
Set of "good" refactorings
applied in the past
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 45
 Conformance with refactorings applied in the past
Refactoring criteria. . .
Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-fine_Amount
-listOfCatalogs
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availab_Book()
+check_Delay_Book()
+check_FineAmount()
+check_ValidityCard()
+close_Librairy()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
+print_Catalog()
+remove_Book()
+reserve_Book()
+return_Book()
+search_Book()
+search_Catalog()
+sort_Catalog()
Catalog
-…
+…()
Book
-…
+…()
Data Class
Data Class
Version 1.0
Move field
Move method
Move method
Move field
Inline class
Extract class Move method
Move method
Move methodExtract class
Extract Interface Extract class
Inline class
Inline class
Librairy_Main_Control
-current_Catalog
-listOfCatalogs
+sort_Catalog()
+add_Book()
+list_Catalogs()
+remove_Book()
+search_Book()
+search_Catalog()
Catalog
-current_Book
+archive_Catalog()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+print_Catalog()
Book
-borrow_date_Book
-return_date_Book
-reserved_Book
+return_Book()
+borrow_Book()
+check_Delay_Book()
+reserve_Book()
+check_Availabi_Book()NewClass_1
-fine_Amount
+chek_FineAmount()
+check_ValidityCard()
+issue_LibrairyCard()
NewClass_2
-librairy_opened
+close_Librairy()
+open_Librairy()
Version 3.0
Librairy_Main_Control
-borrow_date_Book
-current_Book
-current_Catalog
-librairy_opened
-reserved_Book
-return_date_Book
+add_Book()
+archive_Catalog()
+borrow_Book()
+check_Availab_Book()
+check_Delay_Book()
+check_FineAmount()
+display_Book()
+display_Catalog()
+do_Inventory()
+issue_LibrairyCard()
+list_Catalogs()
+open_Librairy()
Catalog
-current_Book
+archive_Catalog()
+create_cheap_Book()
+display_Book()
+display_Catalog()
+do_Inventory()
+print_Catalog()
Book
-borrow_date_Book
-return_date_Book
-reserved_Book
+return_Book()
+borrow_Book()
+check_Delay_Book()
+reserve_Book()
+check_Availabi_Book()
Data Class
Data Class
Version 2.0 Next version
 Studied systems
 Three code-smell types
 Blob, Spaghetti code, and Functional decomposition
 Data
 Collect refactorings from previous versions (Ref-Finder)
 Manual inspection
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 46
Evaluation
Systems Release # classes
# code-
smells
KLOC
GanttProject v1.10.2 245 49 41
Rhino v1.7R1 305 69 42
JFreeChart v1.0.9 521 72 170
JHotDraw v6.1 585 25 21
Xerces-J v2.7.0 991 91 240
Apache Ant v1.8.2 1191 112 255
 Survey
 Questionnaire: evaluate the suggested refactorings
 Sample of 10 refactoring operations
 18 subjects
• graduate/undergraduate students, assistant professors, junior software developers
• Subjects are volunteers and familiar with java programming
• 2 to 13 years experience on Java programming
• 6 groups
 Comparison to state-of-the-art research
 Harman et al 2007, Basic GA approach
 Comparison to other mono and multi-objective algorithms
 MOGA, GA, Random Search
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 47
Empirical evaluation
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 48
Multi-objective refactoring results
Systems Approach CCR RP
Changes
score
Xerces
NSGA-II 83% (55|66) 81 % 3843
Harman et al. '07 N.A 41 % 2669
GA-based approach 89% (59/66) 37 % 4998
JFreeChart
NSGA-II 86% (49|57) 82 % 2016
Harman et al. '07 N.A 36 % 3269
GA-based approach 91% (5257) 37 % 3389
GanttProject
NSGA-II 85% (35|41) 80 % 2826
Harman et al. '07 N.A 23 % 4790
GA-based approach 95% (39|41) 27 % 4697
AntApache
NSGA-II 78% (64|82) 78 % 4690
Harman et al. '07 N.A 40 % 6987
GA-based approach 80% (66|82) 30 % 6797
JHotDraw
NSGA-II 86% (18|21) 80 % 2231
Harman et al. '07 N.A 37 % 3654
GA-based approach % (|21) 43 % 3875
Rhino
NSGA-II 85% (52|61) 80 % 1914
Harman et al. '07 N.A 37 % 2698
GA-based approach 87% (53|61) 32 % 3365
Average
(all systems)
NSGA-II 84% 80 % 2937
Harman et al. '07 N.A 36 % 4011
GA-based approach 89% 34 % 4520
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 49
SBSE validation
0,50
0,55
0,60
0,65
0,70
0,75
0,80
0,85
0,90
CCR
Code-smells Correction Ratio
NSGA-II
GA
MOGA
Random search
0,00
0,10
0,20
0,30
0,40
0,50
0,60
0,70
0,80
0,90
RP
Refactoring Precision
NSGA-II
GA
MOGA
Random search
0
1000
2000
3000
4000
5000
6000
Codechangesscore
Code changes
NSGA-II
GA
MOGA
Random search
 Two intuitions
 Design preservation objectives
 Semantic approximation
 Number of changes
 Conformance with refactoring history
 Quality objectives
 Fix code-smells
 Improve quality indicators
 Introduce design patterns
 …
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 50
Multi-objective formulation
Multi-objective optimization problem
Application 1
Application 2
 Quality FIRST
 Objectives functions
1. Fix code-smells
2. Improve quality indicators
3. Introduce design patterns
 Design preservation
 Constraints to satisfy when applying refactorings
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 51
Application 2: Quality Improvement
 Studied systems
 Code-smells
 God class, Feature Envy, Data Class, and Spaghetti Code
 Design patterns
 Visitor, Factory method, singleton
 Comparison with existing approahes
 Seng et al. ’06, Jensen et al. ’11, Basic GA approach
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 52
Evaluation: Application 2
Systems Release # classes KLOC
# code-
smells
# design
patterns
Xerces-J v2.7.0 991 240 81 36
GanttProject v1.10.2 245 41 49 15
AntApache v1.8.2 1191 255 92 38
JHotDraw v 6.1 585 21 24 18
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 53
Refactoring results
Systems Approaches CCR NP QG
Xerces-J
Application 2 89% 12 0.47
Seng et al. 23% 0 0.54
Jensen et al. 14% 31 0.41
Basic GA approach 88% 0 0.32
GanttProject
Application 2 88% 7 0.34
Seng et al. 24% 1 0.33
Jensen et al. 33% 14 0.35
Basic GA approach 84% 0 0.21
AntApache
Application 2 86% 4 0.5
Seng et al. 7% 0 0.52
Jensen et al. 12% 28 0.51
Basic GA approach 87% 0 0.39
JHotDraw
Application 2 83% 4 0.17
Seng et al. 38% 0 0.19
Jensen et al. 25% 9 0.14
Basic GA approach 88% 0 0.1
Average (all systems)
Application 2 86% 7 0.37
Seng et al. 23% 0.25 0.39
Jensen et al. 21% 20.5 0.35
Basic GA approach 86% 0 0.25
 Quality improvement
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 54
Results
0
0,02
0,04
0,06
0,08
0,1
0,12
0,14
0,16
Reusability Flexibility Understandability Effectiveness Functionality Extendability
QG
QMOOD quality attributes
Xerces-J
GanttProject
AntApache
JHotDraw
 Refactoring meaningfulness
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 55
Results
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
Xerces-J GanttProject AntApache JHotDraw
RP
Application 2
Seng et al.
Jenson et al.
GA-based approach
Outline
 Context and problem
 Research methodology
 Code-smells detection
 Mono-objective software refactoring
 Multi-objective software refactoring
 Conclusion and perspectives
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 56
 First search-based code-smells detection approach
 Search-based approach : GP
 Infer detection rules from code-smell examples
 First mono-objective search-based code-smells correction
 GA: maximize the number of fixed code-smells
 CRO: Prioritize the correction of code-smells
 First multi-objective search-based refactoring approach
 Application 1: preserve design
 Application 2: improve quality
 Validation
 Empirical evaluation
 Very encouraging results
 Comparison with existing approaches
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 57
Conclusion
 Short term
 Code-smells detection
• Consider the change history to improve the detection of code-smells
• Consider other types of code-smells
• Test our approach with other industrial systems
 Refactoring
• Provide a generic GUI-based tool to combine all the proposed approaches
• Additional semantic constraints
• Additional refactoring operations
 An interactive component
• Put the developer in the loop when recommending refactorings
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 58
Future research directions
 Long term
 Detection of code-smells in SOA
 Refactoring of Service-based systems
• Define refactorings in the service level
• Automatically recommend refactorings
 Software migration
 Empirical investigations
• The correlation between code-smells and refactoring proneness
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 59
Future research directions
Journal Papers and Book Chapters
1. Ali Ouni, Marouane Kessentini, Slim Bechick and Houari Sahraoui, Prioritizing Code-smells
Correction Tasks Using Chemical Reaction Optimization, Journal of Software Quality, 2014.
2. Ali Ouni, Marouane Kessentini, Mel Ó Cinnéide, Houari Sahraoui, Multi-criteria Software
Refactoring: Quality, Code Changes, and Semantics Preservation, IEEE Transactions on
Software Engineering, 2014. (under review).
3. Marouane Kessentini, Ali Ouni, Philip Langer, Manuel Wimmer and Slim Bechikh, Search-
based Metamodel Matching with Structural and Syntactic Measures, Journal of Systems and
Software (JSS), 2014.
4. Wael Kessentini, Marouane Kessentini, Houari Sahraoui, Slim Bechikh, and Ali Ouni, A
Cooperative Parallel Search-Based Software Engineering Approach for Code-Smells Detection,
IEEE Transactions on Software Engineering, 2014.
5. Ali Ouni, Marouane Kessentini , Houari Sahraoui and Mohamed Salah Hamdi, Improving Multi-
Objective Code-Smells Correction Using Development History. Journal of Systems and Software
(JSS), 2014. (under revision).
6. Ali Ouni, Marouane Kessentini, Houari Sahraoui, Mel Ó Cinnéide, Kalyanmoy Deb, Automated
Multi-Objective Refactoring to Introduce Design Patterns and Fix Anti-Patterns. Journal of
Automated Software Engineering, 2014. (under submission).
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 60
Publications
7. Ali Ouni, Marouane Kessentini, Houari Sahraoui, Multi-Objective Optimization for Software
Refactoring and Evolution, Elsevier, Advances in Computers, volume 94, pp. 103-167, 2014.
8. Ali Ouni, Marouane Kessentini, Houari Sahraoui and Mounir Boukadoum, Maintainability
Defects Detection and Correction: A Multi-Objective Approach, in Journal of Automated Software
Engineering (JASE), 20(1), pp. 47-79, Springer, 2012.
Refereed Conferences
1. Ali Ouni, Marouane Kessentini, Houari Sahraoui and M. S. Hamdi, The Use of Development
History in Software Refactoring Using a Multi-Objective Evolutionary Algorithm, in the Genetic
and Evolutionay Computation Conference (GECCO), pp. 1461-1468, July 2013, Amesterdam,
The Netherlands,
2. Ali Ouni, Marouane Kessentini and Houari Sahraoui, Search-based Refactoring Using
Recorded Code Changes, in the 17th European Conference on Software Maintenance and
Reengineering (CSMR), pp. 221-230, March 2013, Genova, Italy.
3. Ali Ouni, Marouane Kessentini, Houari Sahraoui and M. S. Hamdi, Search-based Refactoring:
Towards Semantics Preservation. 28th IEEE International Conference on Software Maintenance
(ICSM), pp. 347-356, September 2012, Riva del Garda- Italy.
4. Marouane Kessentini, Wael Kessentini, Houari Sahraoui, Mounir Boukadoum, and Ali Ouni,
Design Defects Detection and Correction by Example. 19th IEEE International Conference on
Program Comprehension (ICPC), pp. 81-90, 22-24 June 2011, Kingston- Canada.
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 61
Publications
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 62
Thank you for your attention
Search-based software engineering
 By Harman and Jones, in 2001
 Formulate software engineering problems as search problems
 Application of optimization techniques
 Genetic algorithm
 Simulated Annealing
 NSGA-II
 …
 SBSE has become a growing research and practice domain
 Software testing
 Requirements engineering
 Model-driven engineering
 Project management
 …
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 63
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 64
 Big picture
Chemical Reaction Optimisation (CRO)
 Semantics
 Minimize semantic errors
 The correctness of proposed refactorings increase when applied to semantically
connected elements
 Semantic constraints
 Vocabulary-based similarity (VS)
 Dependency similarity (DS)
 Implementation similarity (IS)
 Feature inheritance usefulness (FIU)
 Cohesion-based dependency (CD)
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 65
Design semantics
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 66
 CRO mimics the interactions of molecules in a chemical reaction to
search for the global optimum
 Manipulated agents: Molecule
 Energy move
 Analogy
 A container of molecules
Chemical Reaction Optimisation (CRO)
Chemical meaning Metaheuristic meaning
Molecule Solution
Potential energy Objective function value
Collision Change operator
Kinetic energy Measure of tolerance of having worse solutions
Number of Hits Current total number of moves
Minimum structure Current optimal solution
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 67
 A series of events take place
Chemical Reaction Optimisation (CRO)
 Inter-molecular ineffective collision
x1+x2 x1’+x2’
 Synthesis
x1+x2
x’
x x’
 On-wall ineffective collision
 Decomposition
© Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 68
Chemical Reaction Optimisation (CRO)

More Related Content

What's hot

Icsm20.ppt
Icsm20.pptIcsm20.ppt
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
The University of Adelaide
 
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
The University of Adelaide
 
Using HPC Resources to Exploit Big Data for Code Review Analytics
Using HPC Resources to Exploit Big Data for Code Review AnalyticsUsing HPC Resources to Exploit Big Data for Code Review Analytics
Using HPC Resources to Exploit Big Data for Code Review Analytics
The University of Adelaide
 
Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...
The University of Adelaide
 
Improving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer RecommendationsImproving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer Recommendations
The University of Adelaide
 
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
Pavneet Singh Kochhar
 
Investigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective FilesInvestigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective Files
The University of Adelaide
 
Defect Prediction: Accomplishments and Future Challenges
Defect Prediction: Accomplishments and Future ChallengesDefect Prediction: Accomplishments and Future Challenges
Defect Prediction: Accomplishments and Future Challenges
Yasutaka Kamei
 
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
Chakkrit (Kla) Tantithamthavorn
 
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
Feng Zhang
 
Data collection for software defect prediction
Data collection for software defect predictionData collection for software defect prediction
Data collection for software defect prediction
AmmAr mobark
 
Software bug prediction
Software bug prediction Software bug prediction
Software bug prediction
Muthukumaran Kasinathan
 
Cross-project defect prediction
Cross-project defect predictionCross-project defect prediction
Cross-project defect prediction
Thomas Zimmermann
 
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
A Study of the Quality-Impacting Practices of Modern Code Review at Sony MobileA Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
SAIL_QU
 
An Empirical Study of Adoption of Software Testing in Open Source Projects
An Empirical Study of Adoption of Software Testing in Open Source ProjectsAn Empirical Study of Adoption of Software Testing in Open Source Projects
An Empirical Study of Adoption of Software Testing in Open Source Projects
Pavneet Singh Kochhar
 
Crowd debugging (FSE 2015)
Crowd debugging (FSE 2015)Crowd debugging (FSE 2015)
Crowd debugging (FSE 2015)
Sung Kim
 
Survey on Software Defect Prediction
Survey on Software Defect PredictionSurvey on Software Defect Prediction
Survey on Software Defect Prediction
Sung Kim
 
Comparison between Test-Driven Development and Conventional Development: A Ca...
Comparison between Test-Driven Development and Conventional Development: A Ca...Comparison between Test-Driven Development and Conventional Development: A Ca...
Comparison between Test-Driven Development and Conventional Development: A Ca...
IJERA Editor
 
An overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in AndroidAn overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in Android
Vahid Garousi
 

What's hot (20)

Icsm20.ppt
Icsm20.pptIcsm20.ppt
Icsm20.ppt
 
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
 
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
 
Using HPC Resources to Exploit Big Data for Code Review Analytics
Using HPC Resources to Exploit Big Data for Code Review AnalyticsUsing HPC Resources to Exploit Big Data for Code Review Analytics
Using HPC Resources to Exploit Big Data for Code Review Analytics
 
Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...Review Participation in Modern Code Review: An Empirical Study of the Android...
Review Participation in Modern Code Review: An Empirical Study of the Android...
 
Improving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer RecommendationsImproving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer Recommendations
 
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
Adoption of Software Testing in Open Source Projects - A Preliminary Study on...
 
Investigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective FilesInvestigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective Files
 
Defect Prediction: Accomplishments and Future Challenges
Defect Prediction: Accomplishments and Future ChallengesDefect Prediction: Accomplishments and Future Challenges
Defect Prediction: Accomplishments and Future Challenges
 
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
Leveraging HPC Resources to Improve the Experimental Design of Software Analy...
 
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
Cross-project Defect Prediction Using A Connectivity-based Unsupervised Class...
 
Data collection for software defect prediction
Data collection for software defect predictionData collection for software defect prediction
Data collection for software defect prediction
 
Software bug prediction
Software bug prediction Software bug prediction
Software bug prediction
 
Cross-project defect prediction
Cross-project defect predictionCross-project defect prediction
Cross-project defect prediction
 
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
A Study of the Quality-Impacting Practices of Modern Code Review at Sony MobileA Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
 
An Empirical Study of Adoption of Software Testing in Open Source Projects
An Empirical Study of Adoption of Software Testing in Open Source ProjectsAn Empirical Study of Adoption of Software Testing in Open Source Projects
An Empirical Study of Adoption of Software Testing in Open Source Projects
 
Crowd debugging (FSE 2015)
Crowd debugging (FSE 2015)Crowd debugging (FSE 2015)
Crowd debugging (FSE 2015)
 
Survey on Software Defect Prediction
Survey on Software Defect PredictionSurvey on Software Defect Prediction
Survey on Software Defect Prediction
 
Comparison between Test-Driven Development and Conventional Development: A Ca...
Comparison between Test-Driven Development and Conventional Development: A Ca...Comparison between Test-Driven Development and Conventional Development: A Ca...
Comparison between Test-Driven Development and Conventional Development: A Ca...
 
An overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in AndroidAn overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in Android
 

Similar to A Mono- and Multi-objective Approach for Recommending Software Refactoring

Riding the Agile Wave
Riding the Agile WaveRiding the Agile Wave
Riding the Agile Wave
NUS-ISS
 
Dev ops I Best Practices I NuggetHub
Dev ops I Best Practices I NuggetHubDev ops I Best Practices I NuggetHub
Dev ops I Best Practices I NuggetHub
RichardNowack
 
Dev ops as a service
Dev ops as a serviceDev ops as a service
Dev ops as a service
Subroto Bose
 
Collaborative DevOps Approach_ Empowering Software Development.pdf
Collaborative DevOps Approach_ Empowering Software Development.pdfCollaborative DevOps Approach_ Empowering Software Development.pdf
Collaborative DevOps Approach_ Empowering Software Development.pdf
Lucas Lagone
 
Continuous testing & devops with @petemar5hall
Continuous testing & devops with @petemar5hallContinuous testing & devops with @petemar5hall
Continuous testing & devops with @petemar5hall
Peter Marshall
 
Top 20 DevOps Interview Questions.pdf
Top 20 DevOps Interview Questions.pdfTop 20 DevOps Interview Questions.pdf
Top 20 DevOps Interview Questions.pdf
AnanthReddy38
 
Introduction to DevSecOps. An intuitiv approach
Introduction to DevSecOps. An intuitiv approachIntroduction to DevSecOps. An intuitiv approach
Introduction to DevSecOps. An intuitiv approach
FrancisXavierInyanga
 
Increasing Quality with DevOps
Increasing Quality with DevOpsIncreasing Quality with DevOps
Increasing Quality with DevOps
Coveros, Inc.
 
Rational unified process (rup)
Rational unified process (rup)Rational unified process (rup)
Rational unified process (rup)
kdore
 
Software Development Using DevOps
Software Development Using DevOpsSoftware Development Using DevOps
Software Development Using DevOps
Thirupathi Peraboina
 
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
Siva Rama Krishna Chunduru
 
Rup
Rup Rup
DevOps in Software Development Solutions_ Benefits and Best Practices
DevOps in Software Development Solutions_ Benefits and Best PracticesDevOps in Software Development Solutions_ Benefits and Best Practices
DevOps in Software Development Solutions_ Benefits and Best Practices
Tyrion Lannister
 
RUP
RUPRUP
Soft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptxSoft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptx
Kalpna Saharan
 
Regression Testing: Maintaining Software Integrity Over Time
Regression Testing: Maintaining Software Integrity Over TimeRegression Testing: Maintaining Software Integrity Over Time
Regression Testing: Maintaining Software Integrity Over Time
Uncodemy
 
Software coding and testing
Software coding and testingSoftware coding and testing
Software coding and testing
Sandeep Kumar Nayak
 
Improving software economics
Improving software economicsImproving software economics
Improving software economics
deep sharma
 
1.Basic Introduction (1).ppt
1.Basic Introduction (1).ppt1.Basic Introduction (1).ppt
1.Basic Introduction (1).ppt
AshutoshPandey389106
 
The Benefits of DevOps.pdf
The Benefits of DevOps.pdfThe Benefits of DevOps.pdf
The Benefits of DevOps.pdf
MPIRIC Software
 

Similar to A Mono- and Multi-objective Approach for Recommending Software Refactoring (20)

Riding the Agile Wave
Riding the Agile WaveRiding the Agile Wave
Riding the Agile Wave
 
Dev ops I Best Practices I NuggetHub
Dev ops I Best Practices I NuggetHubDev ops I Best Practices I NuggetHub
Dev ops I Best Practices I NuggetHub
 
Dev ops as a service
Dev ops as a serviceDev ops as a service
Dev ops as a service
 
Collaborative DevOps Approach_ Empowering Software Development.pdf
Collaborative DevOps Approach_ Empowering Software Development.pdfCollaborative DevOps Approach_ Empowering Software Development.pdf
Collaborative DevOps Approach_ Empowering Software Development.pdf
 
Continuous testing & devops with @petemar5hall
Continuous testing & devops with @petemar5hallContinuous testing & devops with @petemar5hall
Continuous testing & devops with @petemar5hall
 
Top 20 DevOps Interview Questions.pdf
Top 20 DevOps Interview Questions.pdfTop 20 DevOps Interview Questions.pdf
Top 20 DevOps Interview Questions.pdf
 
Introduction to DevSecOps. An intuitiv approach
Introduction to DevSecOps. An intuitiv approachIntroduction to DevSecOps. An intuitiv approach
Introduction to DevSecOps. An intuitiv approach
 
Increasing Quality with DevOps
Increasing Quality with DevOpsIncreasing Quality with DevOps
Increasing Quality with DevOps
 
Rational unified process (rup)
Rational unified process (rup)Rational unified process (rup)
Rational unified process (rup)
 
Software Development Using DevOps
Software Development Using DevOpsSoftware Development Using DevOps
Software Development Using DevOps
 
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
DevOps For Everyone: Bringing DevOps Success to Every App and Every Role in y...
 
Rup
Rup Rup
Rup
 
DevOps in Software Development Solutions_ Benefits and Best Practices
DevOps in Software Development Solutions_ Benefits and Best PracticesDevOps in Software Development Solutions_ Benefits and Best Practices
DevOps in Software Development Solutions_ Benefits and Best Practices
 
RUP
RUPRUP
RUP
 
Soft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptxSoft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptx
 
Regression Testing: Maintaining Software Integrity Over Time
Regression Testing: Maintaining Software Integrity Over TimeRegression Testing: Maintaining Software Integrity Over Time
Regression Testing: Maintaining Software Integrity Over Time
 
Software coding and testing
Software coding and testingSoftware coding and testing
Software coding and testing
 
Improving software economics
Improving software economicsImproving software economics
Improving software economics
 
1.Basic Introduction (1).ppt
1.Basic Introduction (1).ppt1.Basic Introduction (1).ppt
1.Basic Introduction (1).ppt
 
The Benefits of DevOps.pdf
The Benefits of DevOps.pdfThe Benefits of DevOps.pdf
The Benefits of DevOps.pdf
 

Recently uploaded

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 

Recently uploaded (20)

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 

A Mono- and Multi-objective Approach for Recommending Software Refactoring

  • 1. Department of Computer Science and Operations Research A mono- and Multi-objective Approach for Recommending Software Refactoring Ali Ouni Ph.D. Defense Advisors: Houari Sahraoui (Université de Montréal, Canada) Marouane Kessentini (University of Michigan, USA) 12 November 2014
  • 2. Outline  Context and problem  Research methodology  Code-smells detection  Mono-objective software refactoring  Multi-objective software refactoring  Conclusion and perspectives © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 2
  • 3. Context  Software systems have become prevalent in our everyday life  Software changes frequently  Add new requirements  Adapt to environment changes  Correct bugs  Changing a software can be a challenging task  These changes may degrade their design and QoS  The original developers are not around anymore  Easiness to accommodate changes depends on software quality  Maintain a high level of quality during the life cycle of a software system © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring Univ. de Montréal, Nov. 12th, 2014 3
  • 4. Refactoring  “ The process of improving a code after it has been written by changing its internal structure without changing the external behavior ” (Fowler et al., ‘99)  Examples: Move method, extract class, move attribute, ...  Eclipse, NetBeans, …  Advantages  Improve software quality, maintainability, readability  Provide better software extensibility  Increase the speed at which programmers can write and maintain their code  Challenges…  Manual refactoring is an error-prone task  What are the situations ? What are the refactorings to apply? © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 4
  • 5. Refactoring  Need for recommendation systems © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 5 Identification of refactoring solutions Guarantee behavior preservation Apply refactoring Assess the effect of the refactoring on quality Maintain the consistency with other artifacts (e.g., documentation, ..) Detection of code fragments to improve (e.g., code-smells)
  • 6. Step 1: Code-smells detection  Code-smells  Introduced during the initial design or during evolution  Anomalies, anti-patterns, bad smells, design flaws, …  “ Metaphor ” to describe problems resulting from bad design and programming practices  Time pressure, non-experienced programmers, unintentionally, code decay  Lead to software products suffering by poor performance and QoS  Code difficult to understand, modify, maintain, evolve ... © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 6 Code smells What is that smell? Did you write that code?
  • 7. Code-smell examples  Blob “Procedural-style design leads to one object with numerous responsibilities and most other objects only holding data or executing simple processes” © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 7  Spaghetti code “It is a code with a complex and tangled control structure. This code-smell is characteristic of procedural thinking in object-oriented programming. Spaghetti Code is revealed by classes with no structure, declaring long methods with no parameters, and utilising global variables” Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -fine_Amount -listOfCatalogs -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availabi_Book() +check_Delay_Book() +check_FineAmount() +check_ValidityCard() +close_Librairy() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() +print_Catalog() +remove__Book() +reserve_Book() +return_Book() +search_Book() +search_Catalog() +sort_Catalog() Catalog -… +…() Book -… +…() Data Class Data Class
  • 8. Step 2: Refactoring © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 8 Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -fine_Amount -listOfCatalogs -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availab_Book() +check_Delay_Book() +check_FineAmount() +check_ValidityCard() +close_Librairy() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() +print_Catalog() +remove_Book() +reserve_Book() +return_Book() +search_Book() +search_Catalog() +sort_Catalog() Catalog -… +…() Book -… +…() Data Class Data Class Librairy_Main_Control -current_Catalog -listOfCatalogs +sort_Catalog() +add_Book() +list_Catalogs() +remove_Book() +search_Book() +search_Catalog() Catalog -current_Book +archive_Catalog() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +print_Catalog() Book -borrow_date_Book -return_date_Book -reserved_Book +return_Book() +borrow_Book() +check_Delay_Book() +reserve_Book() +check_Availabi_Book() Data Class NewClass_1 -fine_Amount +chek_FineAmount() +check_ValidityCard() +issue_LibrairyCard() NewClass_2 -librairy_opened +close_Librairy() +open_Librairy() Data Class Blob Refactoring Move method Extract class Move field Inline class …
  • 9. Thesis  Goal “Automated approach for recommending software refactoring”  Generate code-smells detection rules  Find refactoring solutions to fix code-smells while preserving the design semantics © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 9
  • 10. Research methodology © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 10 recommended refactorings Part 2 Mono-objective code-smells correction Generation of detection rules (GP) Mono-objective search- based Refactoring (GA / CRO) detection rules Part 1 Code-smells detection Quality metrics Part 3 Multi-objective refactoring Examples of code-smells Multi-objective search- based Refactoring (NSGA-II) Semantic measures Modification score Code-change history Design-pattern detectors recommended refactorings List of refactoring operations
  • 11.  Context and problem  Research methodology  Code-smells detection  Mono-objective software refactoring  Multi-objective software refactoring  Conclusion and perspectives © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 11 recommended refactorings Part 2 Mono-objective code-smells correction Generation of detection rules (GP) Mono-objective search- based Refactoring (GA / CRO) detection rules Part 1 Code-smells detection Quality metrics Part 3 Multi-objective refactoring Examples of code-smells Multi-objective search- based Refactoring (NSGA-II) Semantic measures Modification score Code-change history Design-pattern detectors recommended refactorings List of refactoring operations Research methodology
  • 12. Code-smells detection  Existing work  Manual (Brown et al. ‘98, Fowler and Beck ‘99)  Metrics-based (Palomba et al ‘13, Marinescu et al. ’04, Salehie et al. ’06, Maiga et al.‘12)  Visual (Dhambri et al. ’08, Langelier et al. ’05)  Symptoms-based (Moha et al. ’08, Murno et al. ‘08) Definition  symptoms  detection algorithm © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 12
  • 13. Problem statement  Difficult to define/express detection rules  Large list of code-smells to categorize  Large exhaustive list of quality metrics  Huge number of possible threshold values  Huge space to explore: An expert to manually write and validate detection rules  Difficult to derive consensual rules  Diverge expert’s opinions  No consensual definition of symptoms  The same symptom could be associated to many code-smell types  Easier to describe examples than translating symptoms into rules Idea: Infer detection rules from code-smell examples © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 13
  • 14. Approach overview © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 14 Part 1 Code-smells detection Generation of code-smells detection rules (Genetic Algorithm) Software quality metrics (CBO, WMC, NOA,…) Code-smells detection rules Examples of code-smells System 2System 1 System 3 Code-smell instance
  • 15. Genetic Programming © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 15 Population of solutions Evaluation Selection Crossover Mutation Optimal or “good” solution found ? Detection rules Yes No START END  Key elements  Representing of individual  Evaluating an individual  Deriving new individuals using genetic operators
  • 16. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 GP adaptation WMC LCOM NOM CBO [1..500] [1..100] Quality metrics NOA  Solution representation 16 1 : Blob 2 : Spaghetti code 3 : Functional decomposition Base of examples Code-smell instance 3 : If (NOA≥4) AND (WMC<3) Then Functional decomposition 2 : If (CBO≥ 151) Then Spaghetti code 1 : If (LOCCLASS≥1500) AND (NOM≥20) OR (WMC>20) Then Blob R1: Blob R2: SC R3: FD OR OR AND AND LOCClASS ≥ 1500 NOM ≥ 20 CBO ≥ 151 NOA ≥ 4 CBO<3 MWC ≥ 20 N6 N1 N2 N3 N4 N5 N7 N8 N10 N9 Tree representation  Fitness function 𝑅𝑒𝑐𝑎𝑙𝑙 = 𝑡𝑟𝑢𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠 𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑐𝑜𝑑𝑒 𝑠𝑚𝑒𝑙𝑙𝑠 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 = 𝑡𝑟𝑢𝑒 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒𝑠 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑑𝑒𝑡𝑒𝑐𝑡𝑒𝑑 𝑐𝑜𝑑𝑒 𝑠𝑚𝑒𝑙𝑙𝑠
  • 17. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 17  Studied systems  Three types of code-smells  Blob, Spaghetti code, Functional decomposition  6-fold cross validation  Detect smells in a system using the 5 other systems  Detection precision and recall Evaluation: detection results Systems # of classes KLOC # of code-smells Quick UML v2001 142 19 11 LOG4J v1.2.1 189 21 17 GanttProject v1.10.2 245 31 41 Xerces-J v2.7.0 991 240 66 ArgoUML v0.19.8 1230 1160 89 AZUREUS v2.3.0.6 1449 42 93
  • 18. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 18 Detection results System Precision Recall GanttProject Blob : 100% SC : 93% FD : 91% 100% 97% 94% Xerces-J Blob : 97% SC: 90% FD: 88% 100% 88% 86% ArgoUML Blob : 93% SC: 88% FD: 82% 100% 91% 89% QuickUML Blob : 94% SC: 84% FD: 81% 98% 93% 88% AZUREUS Blob : 82% SC: 71% FD: 68% 94% 81% 86% LOG4J Blob : 87% SC: 84% FD: 66% 90% 84% 74% Average Blob : 92% SC: 85% FD: 79% 97% 89% 86%
  • 19. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 19 Examples-size variation 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 1 2 3 4 5 Precision Recall Precision, recall % Number of systems
  • 20. Outline  Context and problem  Research methodology  Code-smells detection  Mono-objective software refactoring  Multi-objective software refactoring  Conclusion and perspectives © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 20 recommended refactorings Part 2 Mono-objective code-smells correction Generation of detection rules (GP) Mono-objective search- based Refactoring (GA / CRO) detection rules Part 1 Code-smells detection Quality metrics Part 3 Multi-objective refactoring Examples of code-smells Multi-objective search- based Refactoring (NSGA-II) Semantic measures Modification score Code-change history Design-pattern detectors recommended refactorings List of refactoring operations
  • 21. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 21  Manual approaches – Standard refactorings (Fowler et al. ‘98)  Metric-based approaches – Search-based techniques • Find the best sequence of refactorings (Seng et al. ‘06, Harman et al. ’07, O’Keeffe et al. ’08,) – Analytic approaches • Study of relations between some quality metrics and refactoring changes (Sahraoui et al. ’00, Du Bois et al. ’04, Moha et al. ’08)  Clustering-based approaches – Fix code-smells (Marios et al, ’11, JDeodorant) Existing work on refactoring
  • 22. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 22  Difficult to define "standard" refactorings  Pre-define refactoring solutions for each code-smell type  Difficult to establish the link between refactoring and quality improvement  Improving some quality metrics do not fix code-smells  Is not practical to correct code-smells separately  Correcting a code-smell may produce other code-smells  Do not consider the impact of refactoring  Do not take into consideration the semantic coherence dimension Problem statement
  • 23. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 23  Two scenarios 1. Enough time/resources 2. Time/resources limitations Mono-objective Refactoring recommended refactorings Part 2 Mono-objective code-smells correction Basic Mono-objective Refactoring (GA) Prioritizing code-smells correction (CRO) List of refactoring operations + Detection rules Scenario 1 Scenario 2recommended refactorings
  • 24. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 24 Basic mono-objective refactoring Code to be refactored Suggested refatorings Code-smells detection rules List of possible refactorings Basic Code-smells correction (Genetic Algorithm) Scenario 1
  • 25. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 25  Genetic Algorithm  Solution representation  Individual = Sequence of refactoring operations  Controlling parameters Genetic algorithm adaptation Refactorings Controlling parameters move method (sourceClass, targetClass, method) move field (sourceClass, targetClass, field) pull up field (sourceClass, targetClass, field) pull up method (sourceClass, targetClass, method) push down field (sourceClass, targetClass, field) push down method (sourceClass, targetClass, method) inline class (sourceClass, targetClass) extract class (sourceClass, newClass) 1 moveMethod 2 pullUpAttribute 3 extractClass 4 inlineClass 5 extractSuperClass 6 inlineMethod
  • 26. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 26  Population creation  Population: set of refactoring solutions  Fitness function Genetic algorithm adaptation Correction ratio = # code smells 𝑎𝑓𝑡𝑒𝑟 𝑟𝑒𝑓𝑎𝑐𝑡𝑜𝑟𝑖𝑛𝑔 # detected code smells moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass pullUpAttribute extractClass moveMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass moveMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass moveMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod inlineClass inlineMethod extractSuperClass moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass moveMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass moveMethod moveMethod pullUpAttribute extractClass inlineClass extractSuperClass inlineMethod extractClass pullUpAttribute extractClass moveMethod moveMethod pullUpAttribute extractClass
  • 27. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 27 Evaluation: basic refactoring results System CCR RP GanttProject 95% (39|41) 52 % Xerces-J 89% (59|66) 49 % ArgoUML 85% (76|89) 59 % QuickUML 90% (26|29) 59 % LOG4J 88% (15|17) 51 % AZUREUS 94% (87|93) 57 % Average 90% 54% 𝐂𝐂𝐑 = # 𝐜𝐨𝐝𝐞 𝐬𝐦𝐞𝐥𝐥𝐬 𝐚𝐟𝐭𝐞𝐫 𝐚𝐩𝐩𝐥𝐲𝐢𝐧𝐠 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬 # 𝐜𝐨𝐝𝐞 𝐬𝐦𝐞𝐥𝐥𝐬 𝐛𝐞𝐟𝐨𝐫𝐞 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠 𝐑𝐏 = # 𝐦𝐞𝐚𝐧𝐢𝐧𝐠𝐟𝐮𝐥 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬 # 𝐩𝐫𝐨𝐩𝐨𝐬𝐞𝐝 𝐫𝐞𝐟𝐚𝐜𝐭𝐨𝐫𝐢𝐧𝐠𝐬
  • 28. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 28 Mono-objective Refactoring recommended refactorings Part 2 Mono-objective code-smells correction Basic Mono-objective Refactoring (GA) Prioritizing code-smells correction (CRO) List of refactoring operations + Detection rules Scenario 1 Scenario 2recommended refactorings
  • 29. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 29  Second scenario  Time / resources limitations  Don’t need to fix all code-smells -> only the most critical ones  Idea: Prioritize the correction of code smells Priority-based refactoring Priority-based code-smells correction (Chemical reaction optimisation)Code to be refactored Suggested refatorings Code-smells detection rules List of possible refactorings Prioritisation schema
  • 30. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 30  Four heuristics  Priority  rank code-smells according to the maintainers preferences  Severity  rank code-smells according to a set of design-properties (size, complexity, coupling, cohesion, hierarchy, etc.)  Risk  the risk score corresponds to the deviation from good design practices.  the more code deviates from good practices, the more it is likely to be risky  Importance  the importance of a class corresponds to their change frequency  the more a class undergoes changes, the more it is likely to be problematic  if a code-smell remains unmodified, the system may not experience problems Prioritizing code-smells correction
  • 31. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 31  Goal:  maximize the correction of the critical code-smells  Objective function  weighted sum of the prioritization heuristics  Chemical reaction optimisation (CRO)  Inspired by the phenomenon of chemical reactions  Molecule <--> solution  Potential energy <--> objective function value  Collision <--> change operator (mechanism to find new solution) Prioritizing code-smells correction
  • 32. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 32  Comparison 1. Our CRO-based approach 2. CRO without prioritization 3. Basic GA approach Refactoring comparison results for the five systems from 31 simulation runs Validation: CRO refactoring results
  • 33. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 33  Comparison 1. Chemical Reaction Optimization (CRO) 2. Genetic Algorithm (GA) 3. Simulated Annealing (SA) 4. Particle Swarm Optimisation (PSO) Refactoring comparison results for the five systems from 31 simulation runs SBSE validation
  • 34. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 34  Stability Results 45 47 49 51 53 55 57 59 75 80 85 90 95 100 210 216 222 232 232 236 241 255 257 259 265 268 270 271 271 274 275 276 276 277 277 278 279 280 281 281 282 282 282 285 288 Number of refactorings CCR (%) ICR (%) RCR (%) SCR (%) Time (min) CCR (%), ICR(%), RCR(%) , SCR(%) Time (min)
  • 35. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 35 Refactorings distribution
  • 36. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 36  Advantages  Most of code-smells are fixed  Critical code-smells are fixed first (prioritized)  Limitations  Not all suggested refactoring operations are semantically feasible  Some refactoring solutions requires a considerable number of changes  Single perspective ? Mono-objective formulation
  • 37. Outline  Context and problem  Research methodology  Code-smells detection  Mono-objective software refactoring  Multi-objective software refactoring  Conclusion and perspectives © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 37 recommended refactorings Part 2 Mono-objective code-smells correction Generation of detection rules (GP) Mono-objective search- based Refactoring (GA / CRO) detection rules Part 1 Code-smells detection Quality metrics Part 3 Multi-objective refactoring Examples of code-smells Multi-objective search- based Refactoring (NSGA-II) Semantic measures Modification score Code-change history Design-pattern detectors recommended refactorings List of refactoring operations
  • 38.  Two intuitions  Design preservation objectives  Semantic approximation  Number of changes  Conformance with refactoring history  Quality objectives  Fix code-smells  Improve quality indicators  Introduce design patterns  … © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 38 Multi-objective formulation Multi-objective optimization problem Application 1 Application 2
  • 39.  NSGA-II: Non-dominated Sorting Genetic Algorithm (K. Deb et al., ’02) © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 39 NSGA-II overview Parent Population Offspring Population Non-dominated sorting F1 F2 F3 F4 Crowding distance sorting Population in next generation
  • 40.  Two intuitions  Design preservation objectives  Semantic approximation  Number of changes  Conformance with refactoring history  Quality objectives  Fix code-smells  Improve quality indicators  Introduce design patterns  … © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 40 Multi-objective formulation Multi-objective optimization problem Application 1 Application 2
  • 41. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 41 Application 1: Design preservation FIRST ! Refactoring history Proposed refactorings Semantic measures D Multi-objective Refactoring (NSGA-II) Source code with code-smells Code-smells detection rules List of possible refactorings
  • 42.  Four objective functions 1. Quality  Calculate the number of fixed code-smells 2. Code changes  Calculate the number of atomic changes required when applying refactoring 3. Approximate semantic similarity  Calculate cosine similarity between vocabulary used 4. Maintain the conformance with change history  Calculate a similarity score between the a suggested refactoring and a base of refactorings applied in the past © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 42 NSGA-II adaptation
  • 43. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 43  Number of code changes Refactoring criteria. . . Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -fine_Amount -listOfCatalogs -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availab_Book() +check_Delay_Book() +check_FineAmount() +check_ValidityCard() +close_Librairy() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() +print_Catalog() +remove_Book() +reserve_Book() +return_Book() +search_Book() +search_Catalog() +sort_Catalog() Catalog -… +…() Book -… +…() Data Class Data Class Librairy_Main_Control -current_Catalog -listOfCatalogs +sort_Catalog() +add_Book() +list_Catalogs() +remove_Book() +search_Book() +search_Catalog() Catalog -current_Book +archive_Catalog() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +print_Catalog() Book -borrow_date_Book -return_date_Book -reserved_Book +return_Book() +borrow_Book() +check_Delay_Book() +reserve_Book() +check_Availabi_Book() Data Class NewClass_1 -fine_Amount +chek_FineAmount() +check_ValidityCard() +issue_LibrairyCard() NewClass_2 -librairy_opened +close_Librairy() +open_Librairy() Data Class Blob Refactoring Solution 3 1. Move method 2. Extract class 3. Move field 4. Move method 5. Move method 6. Inline class 7. Move field 8. Extract class 9. Move method 10 Move field Solution 1 1. Move method 2. Extract class 3. Move field 4. Move method 5. Move method Solution 2 1. Move method. 2. Move method 3. Inline class 4. Move field 5. Extract class Solution 4 1. Move method. 2. Move method 3. Inline class 4. Move field 5. Extract class 6. Move field 7. Extract class
  • 44. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 44  Semantic similarity Refactoring criteria. . . Catalog -current_Book +archive_Catalog() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +print_Catalog() Book -borrow_date_Book -return_date_Book -reserved_Book +return_Book() +borrow_Book() +check_Delay_Book() +reserve_Book() +check_Availabi_Book() NewClass_1 -fine_Amount +chek_FineAmount() +check_ValidityCard() +issue_LibrairyCard() NewClass_2 -librairy_opened +close_Librairy() +open_Librairy() Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -fine_Amount -listOfCatalogs -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availabi_Book() +check_Delay_Book() +check_FineAmount() +check_ValidityCard() +close_Librairy() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() +print_Catalog() +remove__Book() +reserve_Book() +return_Book() +search_Book() +search_Catalog() +sort_Catalog() NewClass_1 -fine_Amount +chek_FineAmount() +check_ValidityCard() +issue_LibrairyCard() Code-smell: Blob
  • 45. Set of "good" refactorings applied in the past © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 45  Conformance with refactorings applied in the past Refactoring criteria. . . Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -fine_Amount -listOfCatalogs -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availab_Book() +check_Delay_Book() +check_FineAmount() +check_ValidityCard() +close_Librairy() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() +print_Catalog() +remove_Book() +reserve_Book() +return_Book() +search_Book() +search_Catalog() +sort_Catalog() Catalog -… +…() Book -… +…() Data Class Data Class Version 1.0 Move field Move method Move method Move field Inline class Extract class Move method Move method Move methodExtract class Extract Interface Extract class Inline class Inline class Librairy_Main_Control -current_Catalog -listOfCatalogs +sort_Catalog() +add_Book() +list_Catalogs() +remove_Book() +search_Book() +search_Catalog() Catalog -current_Book +archive_Catalog() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +print_Catalog() Book -borrow_date_Book -return_date_Book -reserved_Book +return_Book() +borrow_Book() +check_Delay_Book() +reserve_Book() +check_Availabi_Book()NewClass_1 -fine_Amount +chek_FineAmount() +check_ValidityCard() +issue_LibrairyCard() NewClass_2 -librairy_opened +close_Librairy() +open_Librairy() Version 3.0 Librairy_Main_Control -borrow_date_Book -current_Book -current_Catalog -librairy_opened -reserved_Book -return_date_Book +add_Book() +archive_Catalog() +borrow_Book() +check_Availab_Book() +check_Delay_Book() +check_FineAmount() +display_Book() +display_Catalog() +do_Inventory() +issue_LibrairyCard() +list_Catalogs() +open_Librairy() Catalog -current_Book +archive_Catalog() +create_cheap_Book() +display_Book() +display_Catalog() +do_Inventory() +print_Catalog() Book -borrow_date_Book -return_date_Book -reserved_Book +return_Book() +borrow_Book() +check_Delay_Book() +reserve_Book() +check_Availabi_Book() Data Class Data Class Version 2.0 Next version
  • 46.  Studied systems  Three code-smell types  Blob, Spaghetti code, and Functional decomposition  Data  Collect refactorings from previous versions (Ref-Finder)  Manual inspection © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 46 Evaluation Systems Release # classes # code- smells KLOC GanttProject v1.10.2 245 49 41 Rhino v1.7R1 305 69 42 JFreeChart v1.0.9 521 72 170 JHotDraw v6.1 585 25 21 Xerces-J v2.7.0 991 91 240 Apache Ant v1.8.2 1191 112 255
  • 47.  Survey  Questionnaire: evaluate the suggested refactorings  Sample of 10 refactoring operations  18 subjects • graduate/undergraduate students, assistant professors, junior software developers • Subjects are volunteers and familiar with java programming • 2 to 13 years experience on Java programming • 6 groups  Comparison to state-of-the-art research  Harman et al 2007, Basic GA approach  Comparison to other mono and multi-objective algorithms  MOGA, GA, Random Search © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 47 Empirical evaluation
  • 48. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 48 Multi-objective refactoring results Systems Approach CCR RP Changes score Xerces NSGA-II 83% (55|66) 81 % 3843 Harman et al. '07 N.A 41 % 2669 GA-based approach 89% (59/66) 37 % 4998 JFreeChart NSGA-II 86% (49|57) 82 % 2016 Harman et al. '07 N.A 36 % 3269 GA-based approach 91% (5257) 37 % 3389 GanttProject NSGA-II 85% (35|41) 80 % 2826 Harman et al. '07 N.A 23 % 4790 GA-based approach 95% (39|41) 27 % 4697 AntApache NSGA-II 78% (64|82) 78 % 4690 Harman et al. '07 N.A 40 % 6987 GA-based approach 80% (66|82) 30 % 6797 JHotDraw NSGA-II 86% (18|21) 80 % 2231 Harman et al. '07 N.A 37 % 3654 GA-based approach % (|21) 43 % 3875 Rhino NSGA-II 85% (52|61) 80 % 1914 Harman et al. '07 N.A 37 % 2698 GA-based approach 87% (53|61) 32 % 3365 Average (all systems) NSGA-II 84% 80 % 2937 Harman et al. '07 N.A 36 % 4011 GA-based approach 89% 34 % 4520
  • 49. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 49 SBSE validation 0,50 0,55 0,60 0,65 0,70 0,75 0,80 0,85 0,90 CCR Code-smells Correction Ratio NSGA-II GA MOGA Random search 0,00 0,10 0,20 0,30 0,40 0,50 0,60 0,70 0,80 0,90 RP Refactoring Precision NSGA-II GA MOGA Random search 0 1000 2000 3000 4000 5000 6000 Codechangesscore Code changes NSGA-II GA MOGA Random search
  • 50.  Two intuitions  Design preservation objectives  Semantic approximation  Number of changes  Conformance with refactoring history  Quality objectives  Fix code-smells  Improve quality indicators  Introduce design patterns  … © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 50 Multi-objective formulation Multi-objective optimization problem Application 1 Application 2
  • 51.  Quality FIRST  Objectives functions 1. Fix code-smells 2. Improve quality indicators 3. Introduce design patterns  Design preservation  Constraints to satisfy when applying refactorings © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 51 Application 2: Quality Improvement
  • 52.  Studied systems  Code-smells  God class, Feature Envy, Data Class, and Spaghetti Code  Design patterns  Visitor, Factory method, singleton  Comparison with existing approahes  Seng et al. ’06, Jensen et al. ’11, Basic GA approach © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 52 Evaluation: Application 2 Systems Release # classes KLOC # code- smells # design patterns Xerces-J v2.7.0 991 240 81 36 GanttProject v1.10.2 245 41 49 15 AntApache v1.8.2 1191 255 92 38 JHotDraw v 6.1 585 21 24 18
  • 53. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 53 Refactoring results Systems Approaches CCR NP QG Xerces-J Application 2 89% 12 0.47 Seng et al. 23% 0 0.54 Jensen et al. 14% 31 0.41 Basic GA approach 88% 0 0.32 GanttProject Application 2 88% 7 0.34 Seng et al. 24% 1 0.33 Jensen et al. 33% 14 0.35 Basic GA approach 84% 0 0.21 AntApache Application 2 86% 4 0.5 Seng et al. 7% 0 0.52 Jensen et al. 12% 28 0.51 Basic GA approach 87% 0 0.39 JHotDraw Application 2 83% 4 0.17 Seng et al. 38% 0 0.19 Jensen et al. 25% 9 0.14 Basic GA approach 88% 0 0.1 Average (all systems) Application 2 86% 7 0.37 Seng et al. 23% 0.25 0.39 Jensen et al. 21% 20.5 0.35 Basic GA approach 86% 0 0.25
  • 54.  Quality improvement © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 54 Results 0 0,02 0,04 0,06 0,08 0,1 0,12 0,14 0,16 Reusability Flexibility Understandability Effectiveness Functionality Extendability QG QMOOD quality attributes Xerces-J GanttProject AntApache JHotDraw
  • 55.  Refactoring meaningfulness © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 55 Results 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% Xerces-J GanttProject AntApache JHotDraw RP Application 2 Seng et al. Jenson et al. GA-based approach
  • 56. Outline  Context and problem  Research methodology  Code-smells detection  Mono-objective software refactoring  Multi-objective software refactoring  Conclusion and perspectives © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 56
  • 57.  First search-based code-smells detection approach  Search-based approach : GP  Infer detection rules from code-smell examples  First mono-objective search-based code-smells correction  GA: maximize the number of fixed code-smells  CRO: Prioritize the correction of code-smells  First multi-objective search-based refactoring approach  Application 1: preserve design  Application 2: improve quality  Validation  Empirical evaluation  Very encouraging results  Comparison with existing approaches © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 57 Conclusion
  • 58.  Short term  Code-smells detection • Consider the change history to improve the detection of code-smells • Consider other types of code-smells • Test our approach with other industrial systems  Refactoring • Provide a generic GUI-based tool to combine all the proposed approaches • Additional semantic constraints • Additional refactoring operations  An interactive component • Put the developer in the loop when recommending refactorings © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 58 Future research directions
  • 59.  Long term  Detection of code-smells in SOA  Refactoring of Service-based systems • Define refactorings in the service level • Automatically recommend refactorings  Software migration  Empirical investigations • The correlation between code-smells and refactoring proneness © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 59 Future research directions
  • 60. Journal Papers and Book Chapters 1. Ali Ouni, Marouane Kessentini, Slim Bechick and Houari Sahraoui, Prioritizing Code-smells Correction Tasks Using Chemical Reaction Optimization, Journal of Software Quality, 2014. 2. Ali Ouni, Marouane Kessentini, Mel Ó Cinnéide, Houari Sahraoui, Multi-criteria Software Refactoring: Quality, Code Changes, and Semantics Preservation, IEEE Transactions on Software Engineering, 2014. (under review). 3. Marouane Kessentini, Ali Ouni, Philip Langer, Manuel Wimmer and Slim Bechikh, Search- based Metamodel Matching with Structural and Syntactic Measures, Journal of Systems and Software (JSS), 2014. 4. Wael Kessentini, Marouane Kessentini, Houari Sahraoui, Slim Bechikh, and Ali Ouni, A Cooperative Parallel Search-Based Software Engineering Approach for Code-Smells Detection, IEEE Transactions on Software Engineering, 2014. 5. Ali Ouni, Marouane Kessentini , Houari Sahraoui and Mohamed Salah Hamdi, Improving Multi- Objective Code-Smells Correction Using Development History. Journal of Systems and Software (JSS), 2014. (under revision). 6. Ali Ouni, Marouane Kessentini, Houari Sahraoui, Mel Ó Cinnéide, Kalyanmoy Deb, Automated Multi-Objective Refactoring to Introduce Design Patterns and Fix Anti-Patterns. Journal of Automated Software Engineering, 2014. (under submission). © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 60 Publications
  • 61. 7. Ali Ouni, Marouane Kessentini, Houari Sahraoui, Multi-Objective Optimization for Software Refactoring and Evolution, Elsevier, Advances in Computers, volume 94, pp. 103-167, 2014. 8. Ali Ouni, Marouane Kessentini, Houari Sahraoui and Mounir Boukadoum, Maintainability Defects Detection and Correction: A Multi-Objective Approach, in Journal of Automated Software Engineering (JASE), 20(1), pp. 47-79, Springer, 2012. Refereed Conferences 1. Ali Ouni, Marouane Kessentini, Houari Sahraoui and M. S. Hamdi, The Use of Development History in Software Refactoring Using a Multi-Objective Evolutionary Algorithm, in the Genetic and Evolutionay Computation Conference (GECCO), pp. 1461-1468, July 2013, Amesterdam, The Netherlands, 2. Ali Ouni, Marouane Kessentini and Houari Sahraoui, Search-based Refactoring Using Recorded Code Changes, in the 17th European Conference on Software Maintenance and Reengineering (CSMR), pp. 221-230, March 2013, Genova, Italy. 3. Ali Ouni, Marouane Kessentini, Houari Sahraoui and M. S. Hamdi, Search-based Refactoring: Towards Semantics Preservation. 28th IEEE International Conference on Software Maintenance (ICSM), pp. 347-356, September 2012, Riva del Garda- Italy. 4. Marouane Kessentini, Wael Kessentini, Houari Sahraoui, Mounir Boukadoum, and Ali Ouni, Design Defects Detection and Correction by Example. 19th IEEE International Conference on Program Comprehension (ICPC), pp. 81-90, 22-24 June 2011, Kingston- Canada. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 61 Publications
  • 62. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 62 Thank you for your attention
  • 63. Search-based software engineering  By Harman and Jones, in 2001  Formulate software engineering problems as search problems  Application of optimization techniques  Genetic algorithm  Simulated Annealing  NSGA-II  …  SBSE has become a growing research and practice domain  Software testing  Requirements engineering  Model-driven engineering  Project management  … © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 63
  • 64. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 64  Big picture Chemical Reaction Optimisation (CRO)
  • 65.  Semantics  Minimize semantic errors  The correctness of proposed refactorings increase when applied to semantically connected elements  Semantic constraints  Vocabulary-based similarity (VS)  Dependency similarity (DS)  Implementation similarity (IS)  Feature inheritance usefulness (FIU)  Cohesion-based dependency (CD) © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 65 Design semantics
  • 66. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 66  CRO mimics the interactions of molecules in a chemical reaction to search for the global optimum  Manipulated agents: Molecule  Energy move  Analogy  A container of molecules Chemical Reaction Optimisation (CRO) Chemical meaning Metaheuristic meaning Molecule Solution Potential energy Objective function value Collision Change operator Kinetic energy Measure of tolerance of having worse solutions Number of Hits Current total number of moves Minimum structure Current optimal solution
  • 67. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 67  A series of events take place Chemical Reaction Optimisation (CRO)  Inter-molecular ineffective collision x1+x2 x1’+x2’  Synthesis x1+x2 x’ x x’  On-wall ineffective collision  Decomposition
  • 68. © Ali Ouni A Mono- and Multi-objective Approach for Recommending Software Refactoring 12 November 2014 68 Chemical Reaction Optimisation (CRO)