Arch
ite
c
tu
re-Drive
n
Software Development using
Acme a
n
d
ArchJa
va
“Never go to sea w ith tw o chrono meters; t a ke one or th Present ation on research in progress
Soft
ware Research Seminar (SSS
G) Jan 12 th 2005
Marwa
n
Abi
-Antoun
Problem Statement
“How
do
es one en
sure
tha
t every triflin
g
deta
il of
an
arch
ite
c
tura
l spe
c
ification
g
e
com
m
unicated
to
the
im
ple
m
enter,
properly un
dersto
od
by him
, a
n
d
accura
tely incorpora
te
d
in
to
the
produ
ct?”
Fred
erick
P. Broo
ks, Jr.,
in
The
Mythical
Man-Mon
th
Conceptual Integrity
•
Importan
c
e
of
a do
cu
mente
d
so
ftware
arch
ite
c
ture
spe
c
ificati
o
n
:
– O utsour cing and/or distrib u ted de velop m ent – S of tware maintenance and evo lut ion•
A
rchitectural mod
e
l either missing
or
obsole
te or ev
ol
v
e
s sep
a
rate
ly fro
m
imple
m
en
ta
tion
•
N
eed to
ch
eck co
nforman
c
e
a
nd kee
p
s
p
ec
if
ic
at
io
n
i
n
s
y
n
c
wit
h
im
p
lem
en
ta
ti
o
n
ArchJava in a Nutshell
•
E
x
tension o
f Jav
a
programmin
g
lan
guage
•
S
pe
ci
fy ar
chite
c
ture
dir
e
ctly
within code:
– C omponent s, Conne ctors, Port s, Glue ... – C ode serve s as do cu ment ation o f ar chit ecture•
G
uara
n
te
e arch
ite
c
tura
l con
forman
c
e
– T ype sy ste m enforce s inter -component communicat ion – C omponent subst itut abilityAcme + ArchJa
va
•
U
se
Acme
to
che
c
k
oth
e
r propertie
s
:
– A rch ite ct ural style – S y s tem beha vior•
U
se
Acme’s to
ol su
pp
ort
(Acme
S
tudio):
– V isua lizat ion – A d v an ced an alyse s : • P erform anc e a nal y s is b a se d o n qu eui ng th eor • R ate m o n o ton ic sched ul abi lit y ana ly sisMain Contribution
•
C
ontin
uou
s/in
cre
m
e
n
ta
l synchronizatio
n
o
an Archite
c
ture
(Acme) and an
Imple
m
e
n
ta
tion
(ArchJav
a)
– Init ial generat ion of Arch Ja va stub s from A c me mode l – Init ial creat io n of Acme model from e x ist ing Arch Ja va imp lementa tion – S yn chronization between e x ist ing Acme model and e x isting Ar ch Ja va imp lement ationIndustrial Experience
•
G
enerate
a
rchite
c
ture
diagra
m
s
– B ox es a n d a rro w s•
G
enerate
U
M
L
cla
s
s d
iagra
m
s
fro
m
ex
isting
cod
e
:
– Pull-in too many
low-le vel details! – S pend time w eeding outpu t (every t ime)
•
N
o way
to
b
ridge
the
ga
p be
twee
n
the
two
– M anual co mp arison – M anual mergeBridging the Gap
•
P
erceiv
ed d
ifficultie
s
:
– R econ stru ct archite c ture f rom imp leme n tation • B reakt h ro ug h: ArchJ a v a – H andle o v erlapping/missing informa tio n • P artia l su ppo rt from Arc h Jav a•
D
ete
c
ting
differen
ce
s:
– F irst step o f synchronizatio n proce s s – A dopt stru ctu ral not te xtual co mparisonTextual Comparison
•
U
sed
by most co
mmo
n
ly
av
ailable tools
•
L
ine-orien
te
d
•
A
rbitrary
ordering
on
u
nordere
d
d
a
ta
•
N
ot su
ita
b
le
for tree
/gra
ph stru
cture
d
da
– X ML f ile s – D ataba se schemas – A rch ite ct ure Descript ion L anguages ( A DLs)•
F
o
c
u
s
on
string labels at
th
e ex
pense
o
other se
ma
ntic attrib
utes
Limitations of Te
Key Ide
a
s
•
U
se
only
archite
c
turally
relev
ant eleme
n
– Ignore cla sse s/ field s not of type component – C an ignore p o rt method s if not in Acme•
Ignore non-essen
tial
d
e
tails:
– N ame s for co nnector s , role s, atta ch ment s,•
C
omp
onen
t in
stan
ce
a
s
orga
nizin
g
en
tity
•
C
o
m
pa
re
bo
th
t
y
pe
s an
d
in
st
a
n
c
e
s
•
T
ype-driv
en
Structural Comparison
•
B
uild
co
mpl
e
te
in
ter
m
e
d
iate
repre
s
en
ta
tion
for Acme an
d
Arch
Jav
a
– Inc lude s ty pe s, in stan ce s, atta chmen ts , …•
C
omp
a
re
in
termed
iate
repre
s
en
ta
tions:
– E xclude parts from co mparison a s need ed•
D
o NOT
ge
nerate
or re
ly on
tag
s
/com
m
ent
s in
A
c
m
e
or
Ar
ch
Ja
v
a
•
D
o
NOT listen to
Ac
me
or
Ar
ch
Jav
a
cha
nge
ev
ents (discon
nected
o
peratio
n)
Structural Comparison Goals
•
B
e able
to dete
c
t:
–M a tc h e s – Insert s – D elete s – R ename s (do NOT treat as Inser t + D e lete)•
N
ot (initially
) supp
orted
:
–M o v e sYour Feedback
•
D
emo
n
stra
tion of
early proto
type
– U nordered co mparison co mpleted la st week – S ome fea tures no t enab led yet•
W
e’re v
e
ry intere
sted
in
your feedb
ack!
– A pproa ch – U sab ili ty – S ugge st ion s f o r improve m ent•
P
eriod
ic d
e
m
on
stra
tion
s
(ou
tside
SSSG)
Currently Supported Scenarios
•
A
rchJav
a Stub
Ge
nera
tion (skip)
– G ener ate Arc h J a v a stubs from Acme M o d e l•
A
rchitectural Import
–Import Acme m ode l from Arc h J a v a impl eme n ta tion
•
A
rchitectural/Cod
e Ev
olution
– A dditiona l co de is added – D etect and create represe n tation in Acme•
A
rchitectural Sy
nchron
iza
tion
– R en am e com p o nents i n Acm e – D etect r ena mes whe n com par in g w ith A rchJ a v aWalkthrough
•
S
etup Syn
c
hroniza
tion
•
C
omp
a
re
Type
Informa
tion
(skippe
d)
•
C
omp
a
re
In
st
an
ce
In
for
m
a
tion
•
G
enerate
Edit Scrip
t
– O nly Acme e d it s supporte d for now•
A
pply
Edit
Script
•
V
isualize
C
hange
s in
AcmeStud
io
Setup Synchronization
•
S
ele
c
t/Cre
a
te
Acme
model:
– C urrent mod e l: select sy st em/represent ation – N ew mode l: select or impor t fa milie s•
S
ele
c
t
a
n
A
rch
Jav
a
pro
ject fro
m
th
e
workspa
c
e
(imp
ort
if ne
ce
ssary)
•
S
ele
c
t the
main co
mp
onen
t cla
s
s
Compare Type Information
•
R
etriev
e types fro
m
Acme
and
Arch
Jav
•
N
ot v
e
ry u
s
eful if
no
Arch
Jav
a
cla
s
se
s
were g
enerated
for Acme
co
mpon
ent
type
s:
– InstanceOnly se tting for ge nerating Arch Ja stub s – M ost commo n ly used set tingView Instance Information
•
C
omp
onen
ts
•P
o
rt
– P ort In volve m ent s – P rovided Met hods – R equired Me thods•
C
onne
ctors
•
A
tt
ac
hm
e
n
ts
•
B
inding
s
•
T
y
p
e
s
for
in
st
an
ce
s
Compare Instance Information
•
A
ssig
ning
Types
a
ffe
cts th
e Ma
tch
ing
– A ssigning a ty pe to a co mponent could mean that the comp onent inherits port from the
type – E .g ., port can be inherited fr om the type
Compare Instance Information
Visualize in AcmeStudio
•
V
isualize
Acme
Model:
– A cme S tudio : no layout eng ine out of the box – Imple mented layout u s ing a force-dire ct ed layout a lgorit hm (JIGGL E)•
A
ccid
en
tal difficulty:
– Layout unrela ted to syn c hroniza tion – A b s olu tely e s sent ial when generating many Acme ele m e n ts auto m atically – B ad/ Missing coordinate s crash Acme St udioApply Edit Script
•
Layout d
e
p
end
s o
n
assign
ed
type
:
– P ort s : inpu t p o rts Æ le ft , o u tput port s Æ right•
C
licking
o
n
‘Cancel’
a
b
andon
s all
cha
nge
•
F
ut
u
re W
o
rk
:
– V erify type s a s signed to Acme ele m ent s to be created – V erify no illeg a l A c me nam es (e.g ., re se rved keywords) will be generate d – A llow u s er to modify edit scriptImported Architecture –
P
art 1
Raw layou
t
currently generated for
syst
Imported Architecture –
P
art 2
Raw layou
t
currently generated for representa
A hard case
•
E
arly Arch
Jav
a
implementa
tio
n
•
P
redates
current Acme model
•
M
any
chan
ges:
– E verything renamed – O ne in sertion (componen t) – S ome dele tio ns (port s )•
S
ub
tree
s are
too
simila
r!
•
A
cme
mod
e
l may
no
t hav
e
require
d/prov
ided method
s
– C annot u s e to distinguish between children upp er split merg e lo wer Ac m eResearch Questions
-1
•
M
is
sing
ty
p
e
in
for
m
a
tio
n in
Ar
ch
Ja
v
a
:
– N o de clared t y pes for ports, conne ctors, …•
M
issing
in
stance info
rmatio
n in
ArchJav
– N o de clared names for po rts, con nectors, atta chmen ts, binding s, …•
F
al
se
po
si
ti
v
e
s:
– “Global” a tt achment s ( A cme) v/ s a tta ch ment spread out a c ross co mpon ents (Ar c h J a v a) – “port invo lve m ent s” minimize structural differen c e s b e tween Acme and Arch Ja vaResearch Questions
-2
•
S
tru
c
tura
l
typing inste
ad o
f no
min
a
l
typing
– J a v a-like lan guages u s e n o minal typing – N ame s are th e mo st easily changed – R ely on add it ional seman tic informa tion•
A
rchitectural type
in
ference:
– U ser-assigne d types for Acme mode l element s to b e created – Is it po ss ible t o infer ( s ome ) ty pes?Research Questions
-3
•
T
ype-che
ck in
cre
m
e
n
ta
l
chan
ge
s/a
ddition
to
Acme
an
d Arch
Jav
a
– N ever pu sh b reaking chan ges (e.g ., cre a te dangling port s , break sub s titu tability , …)•
B
etter
ha
nd
ling of first-cla
s
s co
nne
ctors:
– A ssigning typ e s to conne ct ors, role s – A ssigning rep resentat ion s t o conne ctors – U sin g conne ctor in stan ce s as organizing entit ie s for structural comp arisonStructural Comparison
•
S
ta
ndard
tree-to
-tree correction
proble
m
•
O
rdere
d
Tree
Co
mp
arison
•
U
nordere
d
Tree
Co
mp
arison
– M ay fit proble m doma in be tt er – Less at tent io n than ordere d compariso n – General problem proved
MAX SN P-HARD – A ssumpt ion s can produ ce polynomia l ti me
•
W
e thin
k
w
e
shou
ld ke
ep
b
o
th for now
Ordered Tree Comparison
•
Imple
me
nte
d
Zhan
g-Sa
sha
algorith
m
:
– E xa ct (not ap proxima tion) algorithm – G enerates op tima l Tree Ed it D istan ce – G ood performance (with no optimizat ion)•
O
ur enha
nceme
n
ts:
– S tru c tural in stead of alpha betical ordering – S tring-t o -strin g correction instead of mat c – F orced ma tc hes be tween sele ct ed nod esUnordered Tree Comparison
•
Imple
me
nte
d
ad
ap
tatio
n
o
f
algorith
m
by
Tor
s
ell
o
, Hi
dov
i
a
n
d
Pelillo
•
C
hose
n
assump
tio
n
:
– If two node s mat c h (i.e., either exa c t ma tch rename), so do their pare n ts – O rderdoes matter with
in each sub-tre e ! – T his assu mpt ion can yie ld bad answers: • C reat e ne w co mpo nent whi c h wrap s alr e a d y existi ng c o mp o nents
Usability Questio
n
s
-1
•
U
sing
tree
s
for so
ftware
archite
c
tu
re
v
isualizatio
n
– A symme tric d isp lay of cha nges – R ight-c lick menu to ed it /assign type s – P ropagate up to root dete c ted differen c e s – U sin g tree s fo r other than inheritan ce trees!•
P
re
sen
t
user wi
th
multiple
ch
oi
ce
s
– A llow manual override o f d e tected d iffer enceUsability Questio
n
s –
2
•
A
llow
th
e
u
s
er to
mo
dify th
e e
d
it
scrip
t
– T he allo wed change s no t orthogonal•
S
uppo
rt sa
v
ing
edit script
a
s
“p
atch”
file
– C an be app lied repeatedly•
U
ndo su
pp
ort
•
G
lobal “Fin
d/Replace”
with
regu
lar
ex
pression
s to
spe
c
ify possib
le (p
attern)
matc
hes
(e.g.,
‘in*’
ÅÆ
‘inp
u
t’
, ‘in
1’
,
…)
Engineering Questions
•
G
eneralize imple
m
en
ta
tion
to allow
co
mpa
ring
/merg
ing
be
tween:
– T wo Acme implementa tion s – T wo Arch Ja va imp lemen ta tion s – U sefu l for comparing versions stored
in a conf iguration management sy ste m
•
Layout e
ngine a
s
Acme
Stu
d
io
plu
g
-in:
– M ainly packa ging/licensing issue s – N eed arch ite c tural style-specific render ingFuture Impleme
n
tation Work
•
R
efa
c
tor
Arch
Jav
a
cod
e
ge
nera
tio
n a
s
spe
c
ia
l ca
se
o
f syn
c
hronization
•
A
dd
support
for in
cre
m
enta
l
cha
n
g
e
s in
ArchJav
a
•
Improv
e
lay
out in
sid
e
Acme
representa
tio
•
S
uppo
rt
mo
dify/sav
Generali
ty of Approach
•
O
th
er
Archite
c
ture
Descrip
tio
n L
a
n
guage
s:
– M ain con s ide ration: a v a ila bility of too l support•
O
th
er imple
m
en
ta
tio
n
langua
ge
s a
s
long
a
arch
ite
c
tura
l in
for
m
a
tio
n av
ailable
:
– U se Ja va an notation or C # cu sto m a ttribute to spe c ify a co mponent class – R etrie v e co class’e s from t y pe-library (TLB) or Interfa c e De finition Langua ge (IDL) in Microso COM imp lementation s (V isual Ba sic, Visual C++)Scalability of Approach
•
S
o
m
e parts more
sta
b
le than
o
the
rs
•
S
tart syn
c
h
ronization
o
f large
systems at:
– A cme representation – A rch J a v a co mponent class•
P
olyno
m
ia
l-time
algo
rithms
•
T
ree
stru
cture
a
m
ena
ble to
op
timiza
tion
– Lazy popu lation on node e x pan sion•
E
dit scrip
t u
s
ed
to ke
ep
track
o
f ch
ange
Complementary Approaches
•
W
e
f
o
c
u
s
on
“
u
pst
ream
”
a
c
ti
v
it
ie
s
– A rch ite ct ure ÅÆ Imple m e n tation•
O
th
ers fo
cu
s on
“down
s
trea
m”
a
c
tiv
ities
– C hange I m pa ct Analy s is • E .g., CHIA N TI (fine-grai ne d str u ctura l com par – R efactoring •E clip se s upp ort (textual c o m p a rison )•
N
OT implying a
“wa
terfall”
pro
c
e
s
s
Chianti: Change Impact Analysis of
Ja
va Pro
g
Related Work
•
C
omp
a
ring
and Syn
c
hronizing
Tre
e
-Stru
cture
d
Data
(e
.g
.,
X
M
L, HT
M
L
, SG
ML
– X -Diff, X-Tree Dif f, XML D iff (Microso ft), XML TreeDiff (I BM)•
G
raph
eX
change
La
ng
uage
(GX
L
):
– D escript ion la nguage used in rever s e engineering community to communicate data between re veAcknowledgements
•
N
agi Na
ha
s
– Imple menta tion of ordered and unordered comparison a lgorithms•
B
radley
Schmerl
– H elp w ith AcmeLib and Acme Studio•
D
a
n
ie
l Tu
nk
e
lan
g (
C
S
P
h
.D
.’
98
)
– A uthor of Ja va Intera ct ive Graph Layou t En vironment (J IGGLE ) – http: //ww w -2. c s. cmu .edu/ ~quixo te/References
[1] Den n is Sh asha, Kaizho ng Zhang. Ap proximate Tree Pa ttern Mat c hing , in Pat tern Ma tc hing Algor ithms , A. Apo s tolico a nd Z. Ga lil, Eds. , chapter 14 . O x ford U n iversity Press, 199 7. [2] Ka izh ong Zhang and T ao Jiang. S o me M AX SN P-hard result s con cerning unordered labeled
trees . Inf o rmation Pro c e s sing Let ters, 4 9 :249– 254, 1994. [3] Andrea To rsello , D ž ena Hido vi , Mar c ello Peli llo. Polyn o mial-Time Metrics for At tributed Trees . Dipartimento d i Info rmatica, Università Ca’ F o s cari d i Vene zia . TR C S -2003-19.