12
31. Generic Refactoring for Programming and Modeling Languages Technical University Dresden Department of Computer Science Chair for Software Technology Jan Reimann, Mirko Seifert, Prof. Uwe Aßmann Version 11-1.1, 17.1.11 1.From Code to Models 2.Related Work 3.Role-based Generic Model Refactoring 4.Evaluation 5.Contributions Obligatory Literature Sander Tichelaar, Stéphane Ducasse, Serge Demeyer, and Oscar Nierstrasz. A meta-model for language- independent refactoring. In Proceedings of International Symposium on Principles of Software Evolution (ISPSE '00), pages 157-167. IEEE Computer Society Press, 2000. • doi:10.1109/ISPSE.2000.913233, MOOSE framework http://www.moosetechnology.org/ Jan Reimann, Mirko Seifert, and Uwe Aßmann. Role- based generic model refactoring. In Dorina C. Petriu, Nicolas Rouquette, and Øystein Haugen, editors, MoDELS (2), volume 6395 of Lecture Notes in Computer Science, pages 78-92. Springer, 2010. Best Paper Award. Prof. U. Aßmann, J. Reimann Role-based Generic Model Refactoring Folie 2 von XYZ

!s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Embed Size (px)

Citation preview

Page 1: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

31

. G

ener

ic R

efac

tori

ng

fo

r P

rog

ram

min

g a

nd

M

odel

ing

Lan

gu

ages

Tech

nic

al U

niv

ersi

ty D

resd

en D

epar

tmen

t of

Com

pu

ter

Sci

ence

Cha

ir for

Sof

twar

e Te

chno

logy

Jan

Rei

man

n,

Mir

ko S

eife

rt,

Pro

f. U

we

man

n

Ver

sion

11-

1.1,

17.

1.11

1. Fr

om C

ode

to M

odel

s 2. R

elat

ed W

ork

3. R

ole-

base

d G

ener

ic M

odel

Ref

acto

ring

4. Ev

alua

tion

5. C

ontr

ibut

ions

Obl

igat

ory

Lite

ratu

re

• San

der

Tich

elaa

r, S

téph

ane

Duc

asse

, Ser

ge D

emey

er,

and

Osc

ar N

iers

tras

z. A

met

a-m

odel

for

lang

uage

-in

depe

nden

t re

fact

orin

g. I

n Pr

ocee

ding

s of

Inte

rnat

iona

l Sym

posi

um o

n Pr

inci

ples

of Sof

twar

e Ev

olut

ion

(ISPS

E '0

0),

p

ages

157

-167

. IE

EE

Com

pute

r Soc

iety

Pre

ss,

2000

.

• do

i:10

.110

9/IS

PSE.

2000

.913

233,

• 

MO

OSE

fram

ewor

k ht

tp:/

/ww

w.m

oose

tech

nolo

gy.o

rg/

• Ja

n Rei

man

n, M

irko

Sei

fert

, an

d U

we

Aßm

ann.

Rol

e-ba

sed

gene

ric

mod

el r

efac

toring

. In

Dor

ina

C.

Petr

iu,

Nic

olas

Rou

quet

te,

and

Øys

tein

Hau

gen,

e

dito

rs,

MoD

ELS (

2),

volu

me

6395

of Le

ctur

e N

otes

in

Com

pute

r Sci

ence

, pa

ges

78-9

2. S

prin

ger,

201

0.

Bes

t Pa

per

Aw

ard.

Prof

. U

. Aßm

ann,

J.

Reim

ann

Rol

e-ba

sed

Gen

eric

Mod

el R

efac

toring

Fo

lie 2

von

XYZ

Page 2: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

An

Exam

ple

of C

ode

Ref

acto

ring

Ex

trac

t M

etho

d (O

utlin

ing)

Prof

. U

. Aßm

ann,

J.

Reim

ann

Slid

e 3

From

Cod

e to

Mod

els

W

hy is

Ref

acto

ring

nee

ded

for

Mod

els?

• M

odel

-Drive

n Sof

twar

e D

evel

opm

ent:

• 

Mod

els

are

part

ial c

ode

• M

odel

s ar

e pr

imar

y ar

tefa

cts

in M

DSD

• 

Goo

d m

odel

des

ign

is e

ssen

tial f

or u

nder

stan

dabi

lity

• Som

e m

odel

s ar

e do

mai

n-sp

ecifi

c, a

nd b

elon

g to

d

omai

n-s

pec

ific

lan

gu

ages

(D

SL)

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 4

Wh

y sh

ould

it b

e g

ener

ic?

• Kno

wn

code

ref

acto

ring

s ar

e tr

ansf

erab

le t

o m

any

DSLs

• 

Cor

e st

eps

of r

efac

toring

s ar

e eq

ual f

or d

iffer

ent

met

amod

els

• A lo

t of

add

ition

al e

ffor

t to

spe

cify

ref

acto

ring

s fr

om s

crat

ch

Page 3: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Rel

ated

Wor

k –

Lim

itatio

ns

M3

laye

r sp

ecifi

catio

n

• Com

mon

met

a-m

etam

odel

to

stat

ic

• La

ck o

f ex

act

cont

rol o

f st

ruct

ures

to

be r

efac

tore

d

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 5

M3

M2

Common

 Object-­‐Orie

nted

 Meta-­‐Metam

odel

Target  M

etam

odel

Adaptatio

n

Based  on

[Moh

a, N

aoue

l, Vin

cent

Mah

é, O

livie

r Bar

ais

und

Jean

-Mar

c Jé

zéqu

el:

Gen

eric

Mod

el R

efac

toring

s, M

OD

ELS 2

009]

Rel

ated

Wor

k –

Lim

itatio

ns

M2

laye

r sp

ecifi

catio

n

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 6

• N

o ge

nerici

ty

• N

o re

use

M2

Target  M

etam

odel

Based  on

[Tae

ntze

r, G

abriel

e, D

irk

Mül

ler

and

Tom

Men

s: S

peci

fyin

g D

omai

n-Spe

cific

Ref

acto

ring

s fo

r And

roM

DA B

ased

on

Gra

ph T

rans

form

atio

n, A

GTI

VE

2007

]

Page 4: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Rel

ated

Wor

k –

Lim

itatio

ns

M1

laye

r sp

ecifi

catio

n

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 7

• N

o ge

nerici

ty

• N

o re

use

M2

M1

Target  M

etam

odel

Exam

ple  Mod

elProp

agation  into

Recorded

 in

[Bro

sch,

Pet

ra,

Phili

p La

nger

, M

artin

a Sei

dl,

Konr

ad W

iela

nd,

Man

uel W

imm

er,

Ger

ti Ka

ppel

, W

erne

r Re

tsch

itzeg

ger

and

Wie

land

Sch

win

ger:

An

Exam

ple

is W

orth

a T

hous

and

Wor

ds:

Com

posi

te O

pera

tion

Mod

elin

g By-

Exam

ple,

M

OD

ELS 2

009]

31

.2 M

OO

SE

Prof

. U

. Aßm

ann,

J.

Reim

ann

Rol

e-ba

sed

Gen

eric

Mod

el R

efac

toring

Fo

lie 8

von

XYZ

Page 5: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

FAM

IX U

pper

Met

amod

el

Prof

. U

. Aßm

ann,

J.

Reim

ann

Rol

e-ba

sed

Gen

eric

Mod

el R

efac

toring

Fo

lie 9

von

XYZ

http

://w

ww

.moo

sete

chno

logy

.org

/?_s

=5k

2-x-

GD

Jjdd

2YIX

• Th

e FA

MIX

upp

er m

etam

odel

• 

Enab

les

gene

ric

refa

ctor

ing

for

all e

ntiti

es a

bove

m

etho

ds,

clas

s re

stru

ctur

ings

, et

c.

• Th

e M

OO

SE

fram

ewor

k su

pplie

s ba

sic

grap

h al

gorith

ms

for

reen

gine

erin

g an

d re

fact

orin

g:

• Str

ongl

y co

nnec

ted

com

pone

nts

• D

omin

ance

• 

Kru

skal

spa

nnin

g tr

ees

• Con

cept

rec

ogni

tion

in t

exts

• 

Form

al c

once

pt a

naly

sis

Prof

. U

. Aßm

ann,

J.

Reim

ann

Rol

e-ba

sed

Gen

eric

Mod

el R

efac

toring

Fo

lie 1

0 vo

n XYZ

Page 6: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

31

.2 R

efac

tory

The

gene

ric

refa

ctor

er o

f TU

Dre

sden

Ja

n Rei

man

n

Prof

. U

. Aßm

ann,

J.

Reim

ann

Des

ign

Patt

erns

and

Fra

mew

orks

Fo

lie 1

1 vo

n XYZ

Rol

e-ba

sed

Gen

eric

Mod

el

Ref

acto

ring

• D

efin

ition

of co

llabo

ratio

ns o

f ob

ject

s in

diff

eren

t co

ntex

ts

• H

ere:

Con

text

= m

odel

ref

acto

ring

• 

Part

icip

ants

pla

y ro

le in

con

cret

e re

fact

orin

g à

Rol

e M

odel

• 

Rol

e-ba

sed

tran

sfor

mat

ion à

Ref

acto

ring

Spe

cific

atio

n • 

App

licat

ion

to d

esired

par

ts o

f m

etam

odel

à R

ole

Map

ping

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 12

Rol

e-b

ased

Des

ign

(R

een

skau

g,

Rie

hle

& G

ross

)

DSL

User

DSL

Desig

ner

Refactoring  

Desig

ner

Role  

Mod

elDS

L  Meta  

Mod

elRe

factoring  

Specificatio

n

DSL  Mod

elRe

factored

DSL  Mod

el

Role  

Mapping

refers  to

inpu

t  for

instance  of

Refactoring  

Interpreter

returns

Page 7: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Rol

e-ba

sed

Gen

eric

Mod

el

Ref

acto

ring

• Ref

acto

ry s

ees

a ro

le m

odel

(a

view

) of

the

m

etam

odel

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 13

Rol

e-b

ased

Met

amod

elin

g

DSL

Des

igne

r Re

f. D

esig

ner

DSL

Use

r

Rol

e-ba

sed

Gen

eric

Mod

el

Ref

acto

ring

• Th

e ro

les

of t

his

role

-met

amod

el c

an b

e us

ed t

o w

rite

re

fact

orin

g sc

ript

s an

d op

erat

ors

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 14

Ref

acto

rin

g S

pec

ific

atio

n o

n R

ole

Mod

el DSL

Des

igne

r Re

f. D

esig

ner

DSL

Use

r

Page 8: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Rol

e-ba

sed

Gen

eric

Mod

el

Ref

acto

ring

• A m

app

ing

map

s ro

les

to m

etac

lass

es in

a c

oncr

ete

met

amod

el

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 15

Rol

e M

app

ing

to

Sp

ecif

ic D

DL

DSL

Des

igne

r Re

f. D

esig

ner

DSL

Use

r

Eval

uatio

n of

Ref

acto

ry

Sta

rtin

g po

int

• 16

tar

get

met

amod

els

of d

iffer

ent

com

plex

ity (

Java

, U

ML,

Ec

ore…

) • 

53 c

oncr

ete

mod

el r

efac

toring

s Res

ult

• 9

gene

ric

mod

el r

efac

toring

s • 

6 m

etam

odel

spe

cific

ext

ensi

ons

wer

e ne

eded

• 

7 m

etam

odel

s ar

e m

ultip

le t

arge

t of

sam

e m

odel

ref

acto

ring

• 

2 m

etam

odel

s ar

e at

leas

t ta

rget

of ev

ery

mod

el r

efac

toring

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 16

Page 9: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Com

pone

nt

A

Rea

l-tim

e

Saf

ety

Dyn

a m

ics

Ene

rgy

Com

pone

nt

B

Rea

l-tim

e co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

1)

Safe

ty c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

2)

Dyn

amic

s co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

3)

Ener

gy c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

4)

New

: M

ulti-

Qua

lity

Con

trac

ts in

CPS

(M

ulti-

Tech

nica

l Spa

ces)

Com

pone

nt

B

Rea

l-tim

e co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

1)

Safe

ty c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

2)

Dyn

amic

s co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

3)

New

: M

ulti-

Qua

lity

Con

trac

ts in

CPS

(M

ulti-

Tech

nica

l Spa

ces)

Ref

acto

rer

1

Ref

acto

rer

2

Ref

acto

rer

3

Ref

acto

rer

4

Com

pone

nt

A

Rea

l-tim

e

Saf

ety

Dyn

a m

ics

Ene

rgy

Ener

gy c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

4)

Page 10: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Com

pone

nt

B

Rea

l-tim

e co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

1)

Safe

ty c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

2)

Dyn

amic

s co

ntra

ct c

heck

ing

(Tec

hnic

al S

pace

3)

New

: M

ulti-

Qua

lity

Con

trac

ts in

CPS

(M

ulti-

Tech

nica

l Spa

ces)

Ref

acto

rer

1

Ref

acto

rer

2

Ref

acto

rer

3

Ref

acto

rer

4

Gen

eric

R

efac

tore

r

Com

pone

nt

A

Rea

l-tim

e

Saf

ety

Dyn

a m

ics

Ene

rgy

Ener

gy c

ontr

act c

heck

ing

(Tec

hnic

al S

pace

4)

Less

ons

Lear

ned

• Ref

acto

ring

s ge

nerica

lly s

peci

fiabl

e if

abst

ract

able

and

st

ruct

ural

ly t

rans

fera

ble

• M

etam

odel

-spe

cific

ref

acto

ring

s po

ssib

le

• D

esig

n de

cisi

ons

• ”S

peci

fic”

gene

ric

refa

ctor

ing

• M

etam

odel

-spe

cific

ext

ensi

on o

r • 

Impl

emen

tatio

n of

met

amod

el-s

peci

fic r

efac

toring

(Ja

va)

• Reu

se b

enef

icia

l if m

odel

ref

acto

ring

app

liabl

e to

at

leas

t tw

o m

etam

odel

s

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 20

Page 11: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Con

trib

utio

ns

• G

ener

ic r

efac

toring

wor

ks!!

• D

efin

ition

of ge

neric

mod

el r

efac

toring

s ba

sed

on r

oles

• 

Rol

e m

odel

s fo

rm a

ded

icat

ed c

onte

xt for

eve

ry m

odel

re

fact

orin

g • 

App

roac

h al

low

s bo

th for

gen

eric

ity a

nd c

ontr

ol o

f th

e st

ruct

ures

to

be r

efac

tore

d • 

Con

trol

is a

chie

ved

by m

appi

ng o

f ro

le m

odel

s in

to

arbi

trar

y se

ctio

ns o

f th

e ta

rget

met

amod

el

• In

terp

reta

tion

by r

esol

ving

rol

es a

nd c

olla

bora

tions

in

to t

he t

arge

t m

etam

odel

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 21

Con

trib

utio

ns

• Pr

e- a

nd p

ostc

ondi

tions

with

rol

e-ba

sed

OCL

inte

rpre

ter

• Pr

eser

vatio

n of

beh

avio

r w

ith for

mal

izat

ion

of

sem

antic

s • 

Spe

cific

atio

n of

mod

el s

mel

ls

• Co-

Ref

acto

ring

• 

Aut

omat

ic m

appi

ng t

o m

etam

odel

s

Prof

. U

. Aßm

ann,

J.

Reim

ann

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Slid

e 22

Ou

tloo

k

Page 12: !s 4. 3. !d 2. !d !m - st.inf.tu-dresden.dest.inf.tu-dresden.de/files/teaching/ws12/dpf/slides/31-dpf-generic-refactorings-2x1.pdfpts and s g g n le Model f. d ic g ¥! A g ps es

Prof

. U

. Aßm

ann,

J.

Reim

ann

Slid

e 23

jan

.rei

man

n@

tu-d

resd

en.d

e

Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

htt

p:/

/w

ww

.em

ftex

t.or

g/

refa

ctor

ing

Stu

den

ts lo

oked

for

in R

esu

bic

Lab

C

o-R

efac

tori

ng

of

mu

lit-q

ual

ity

spec

ific

atio

s h

ttp

://

resu

bic

.in

f.tu

-dre

sden

.de

Prof

. U

. Aßm

ann,

J.

Reim

ann

Slid

e 24

Map

ping

to

Path

s Role

-bas

ed G

ener

ic M

odel

Ref

acto

ring

Classifier

Generalization

1 s

peci

ficge

nera

lizat

ion

0..*

1 g

ener

al

Sub

Ele

men

t

Sup

erE

lem

ent

SubElement

SuperElement