icsm10b.ppt

34
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

Upload: ptidej-team

Post on 25-Jun-2015

36 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: ICSM10b.ppt

Playing with RefactoringIdentifying Extract Class Opportunities through Game TheoryGabriele 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

Page 2: ICSM10b.ppt

contents

ContextRefactoring Software Systems: Why and How

Game Theory BackgroundThe Prisoner’s Dilemma

Game Theory meets SEGame-based Extract Class Refactoring

Page 3: ICSM10b.ppt

Game TheoryBackground

The Prisoner’s Dilemma

Page 4: ICSM10b.ppt

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

Page 5: ICSM10b.ppt

The Prisoner’s Dilemma

TomTom

confess not confess

Sallyconfess (5, 5) (0, 7)

Sallynot confess (7, 0) (4, 4)

Page 6: ICSM10b.ppt

The Prisoner’s Dilemma

TomTom

confess not confess

Sallyconfess (5, 5) (0, 7)

Sallynot confess (7, 0) (4, 4)

NASHEQUILIBRIUM

Page 7: ICSM10b.ppt

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

Page 8: ICSM10b.ppt

Context

Refactoring Software Systems: Why and How

Page 9: ICSM10b.ppt

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

Page 10: ICSM10b.ppt

Focusing on Class Cohesion- How strongly related and focused the

various responsibilites of a class are

- High cohesion is desiderable ... easier maintenance

classclassclass

classclassclass

class

- Programmers often add wrong responsibilities to a class

- The class becomes too complex and its cohesion decreases

Page 11: ICSM10b.ppt

Focusing on Class Cohesion- How strongly related and focused the

various responsibilites of a class are

- High cohesion is desiderable ... easier maintenance

classclass

class Extract Class Refactoring

Splitting a class with many responsibilities into different classes

Page 12: ICSM10b.ppt

Game Theorymeets SE

Game-based Extract Class Refactoring

Page 13: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

Page 14: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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

Page 15: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

Page 16: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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

Page 17: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

Page 18: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

NASHEQUILIBRIUM

Page 19: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

NASHEQUILIBRIUM

Page 20: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

NASHEQUILIBRIUM

Page 21: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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)

NASHEQUILIBRIUM

Page 22: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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

Page 23: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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 NASHEQUILIBRIUM

Page 24: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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 NASHEQUILIBRIUM

Page 25: ICSM10b.ppt

Playing with RefactoringModelling a

non-cooperative game

..choosing the better strategy

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 NASHEQUILIBRIUM

m3

Page 26: ICSM10b.ppt

PreliminaryEvaluation

Game-based Extract Class Refactoring

Page 27: ICSM10b.ppt

Case Study Design

Goal Systems Metrics

RQ1 Comparison with Pareto Optimum ArgoUML, JHotDraw F-measure

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

Page 28: ICSM10b.ppt

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

original system

System mutation

Comparision of orginal

and mutated system

mutated system

refactored system

System refactoring

results

88%

F-MEASURE

Page 29: ICSM10b.ppt

Results

System Game Theory

Pareto Optimum

MaxFlowMinCut

ArgoUML 90% 88% 77%

JHotDraw 85% 82% 76%

Page 30: ICSM10b.ppt

Conclusion andFuture Work

Page 31: ICSM10b.ppt

Conclusion...

The first recommendation system that exploits game theory techniques

Page 32: ICSM10b.ppt

Conclusion...

Preliminary evaluation of the proposed approach

Page 33: ICSM10b.ppt

...and Future Work

investigate about other kind of games, e.g., cooperative game

direct comparison with clustering and search-based approach

apply Game Theory to Software Re-modularization

Page 34: ICSM10b.ppt

Thank you!

Questions and/or comments

Gabriele BavotaPhD StudentDMI - University of [email protected]