Playing with Refactoring Identifying Extract Class Opportunities - - PowerPoint PPT Presentation

playing with refactoring
SMART_READER_LITE
LIVE PREVIEW

Playing with Refactoring Identifying Extract Class Opportunities - - PowerPoint PPT Presentation

Playing with Refactoring Identifying Extract Class Opportunities through Game Theory Gabriele Bavota*, Rocco Oliveto*, Andrea De Lucia* Giuliano Antoniol , Yann-Gal Guhneuc * DMI, University of Salerno, Fisciano (SA), Italy


slide-1
SLIDE 1

Playing with Refactoring

Identifying Extract Class Opportunities through Game Theory

Gabriele Bavota*, Rocco Oliveto*, Andrea De Lucia* Giuliano Antoniol✝, Yann-Gaël Guéhéneuc✝

* DMI, University of Salerno, Fisciano (SA), Italy

✝ DGIGL, École Polytechnique de Montreál, Québec, Canada

slide-2
SLIDE 2

contents

Context

Refactoring Software Systems: Why and How

Game Theory Background

The Prisoner’s Dilemma

Game Theory meets SE

Game-based Extract Class Refactoring

slide-3
SLIDE 3

Game Theory Background

The Prisoner’s Dilemma

slide-4
SLIDE 4

Game Theory

  • is a branch of mathematics widely applied in

the social sciences

  • capture behavior in strategic situations, in

which an individual’s success in making choices depends on the choices of others

  • a game consists of:
  • a set of players (2 or more);
  • a set of moves available to those players;
  • payoffs for each combination of moves
slide-5
SLIDE 5

The Prisoner’s Dilemma

Tom Tom confess not confess Sally confess (5, 5) (0, 7) Sally not confess (7, 0) (4, 4)

slide-6
SLIDE 6

The Prisoner’s Dilemma

Tom Tom confess not confess Sally confess (5, 5) (0, 7) Sally not confess (7, 0) (4, 4)

N A S H E Q U I L I B R I U M

slide-7
SLIDE 7

Game Theory: Summarizing

  • Natural application in strategic situations
  • How to find a compromise between

contrasting goals (Nash Equilibrium)

  • In software engineering:
  • optimal solution to many problems

involves finding a compromise between contrasting goals, e.g., create classes with high cohesion and low coupling

slide-8
SLIDE 8

Context

Refactoring Software Systems: Why and How

slide-9
SLIDE 9

Refactoring ... Why?

  • Changing software without modifying its

external behaviour

  • Improve non-functional attributes of the

software

?

  • Software evolution ... continuous changes
  • Changes cause a drift of the original design,

reducing its quality, e.g., Class Cohesion

slide-10
SLIDE 10

Focusing on Class Cohesion

  • How strongly related and focused the

various responsibilites of a class are

  • High cohesion is desiderable ... easier

maintenance

class

class

class

class

class

class

class

  • Programmers often add wrong

responsibilities to a class

  • The class becomes too complex and its

cohesion decreases

slide-11
SLIDE 11

Focusing on Class Cohesion

  • How strongly related and focused the

various responsibilites of a class are

  • High cohesion is desiderable ... easier

maintenance class

class

class

Extract Class Refactoring

Splitting a class with many responsibilities into different classes

slide-12
SLIDE 12

Game Theory meets SE

Game-based Extract Class Refactoring

slide-13
SLIDE 13

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

slide-14
SLIDE 14

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

(-1, -1) if i = j

slide-15
SLIDE 15

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

0.70 = sim(m1, m2) - sim(m1, m4)

slide-16
SLIDE 16

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

0.70 = sim(m1, m2) - sim(m1, m4)

COHESION COUPLING

slide-17
SLIDE 17

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

slide-18
SLIDE 18

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

NASH EQUILIBRIUM

slide-19
SLIDE 19

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

NASH EQUILIBRIUM

slide-20
SLIDE 20

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

NASH EQUILIBRIUM

slide-21
SLIDE 21

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m2 m3 m4 N m2 m3 m4 N m1 m5

(-1.00, -1.00) (-1.00, -1.00) (0.49, 0.22) (0.70, 0.80) (0.70, 0.50) (-0.49, -0.24) (0.21, 0.58) (0.21, 0.28) (-0.21, -0.58) (-0.70, -0.80) (-1.00, -1.00) (0.00, -0.30) (0.29, 0.22) (-0.20, 0.00) (0.50, 0.80) (-1.00, -1.00)

NASH EQUILIBRIUM

slide-22
SLIDE 22

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m3 N m3 N m1 m5

(-1.00, -1.00) (0.21, 0.28) (0.29, 0.22) (-1.00, -1.00)

m4 m2

slide-23
SLIDE 23

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m3 N m3 N m1 m5

(-1.00, -1.00) (0.21, 0.28) (0.29, 0.22) (-1.00, -1.00)

m4 m2

NASH EQUILIBRIUM

slide-24
SLIDE 24

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

m3 N m3 N m1 m5

(-1.00, -1.00) (0.21, 0.28) (0.29, 0.22) (-1.00, -1.00)

m4 m2

NASH EQUILIBRIUM

slide-25
SLIDE 25

Playing with Refactoring

Modelling a non-cooperative game

. . c h

  • s

i n g t h e b e t t e r s t r a t e g y

T S

N m3 N m1 m5

(-1.00, -1.00) (0.21, 0.28) (0.29, 0.22) (-1.00, -1.00)

m4 m2

NASH EQUILIBRIUM

m3

slide-26
SLIDE 26

Preliminary Evaluation

Game-based Extract Class Refactoring

slide-27
SLIDE 27

Case Study Design

Goal Systems Metrics RQ1

Comparison with Pareto Optimum ArgoUML, JHotDraw F-measure

RQ2

Comparison with others Extract Class Refactoring approaches ArgoUML, JHotDraw F-measure

slide-28
SLIDE 28

Experiment Execution

method1 ... methodn attr1 ... attrm Original Class C1 method1 ... methods attr1 ... attrm Original Class C1 method1 ... methodn attr1 ... attrm

Original Class Ci

method1 ... methodn attr1 ... attrm Original Class C1 method1 ... methody attr1 ... attrm Original Class C1 method1 ... methodn+s attr1 ... attrm+k

Mutated Class Ci + Cj

method1 ... methodn attr1 ... attrm Original Class C1 method1 ... methods attr1 ... attrm Original Class C1 method1 ... methodk attr1 ... attrh

Refactored Class C'i

Input

  • riginal system

System mutation Comparision of orginal and mutated system mutated system refactored system System refactoring results

8 8 %

F-MEASURE

slide-29
SLIDE 29

Results

System Game Theory Pareto Optimum MaxFlow MinCut

ArgoUML 90% 88% 77% JHotDraw 85% 82% 76%

slide-30
SLIDE 30

Conclusion and Future Work

slide-31
SLIDE 31

Conclusion...

The first recommendation system that exploits game theory techniques

slide-32
SLIDE 32

Conclusion...

Preliminary evaluation of the proposed approach

slide-33
SLIDE 33

...and Future Work

i n v e s t i g a t e a b

  • u

t

  • t

h e r k i n d

  • f

g a m e s , e . g . , c

  • p

e r a t i v e g a m e d i r e c t c

  • m

p a r i s

  • n

w i t h c l u s t e r i n g a n d s e a r c h

  • b

a s e d a p p r

  • a

c h

apply Game Theory to Software Re-modularization

slide-34
SLIDE 34

Thank you!

Questions and/or comments

Gabriele Bavota PhD Student DMI - University of Salerno gbavota@unisa.it