180 likes | 258 Views
Structural Manipulations of Software Architecture Using Tarski Relational Algebra. Paper at WCRE '98: Working Conference on Reverse Engineering, Honolulu, Oct 1998. Ric Holt University of Waterloo, Canada holt@uwaterloo.ca. Top view of concrete software architecture of 250KLOC system.
E N D
Structural Manipulations of Software Architecture Using Tarski Relational Algebra Paper at WCRE '98: Working Conference on Reverse Engineering, Honolulu, Oct 1998. Ric Holt University of Waterloo, Canada holt@uwaterloo.ca
Top view of concrete software architecture of 250KLOC system
Process of view creation Source code Clustering Parser Facts extracted from code Hierarchic decomposition Grok: Fact manipulator Architectural diagram Layouter Browser
r C C r a b I a I b z C C C E C C w E U U x y v w x y z v U U Example typed graph • C = { (r,a), (r,b), (a,v), (a,w) (a,x), (b,y), (b,z) } • I = { (a,b) } • E = { (b,y) } • U = { (v,w), (x,y) }
Algebraic Operators Union I + E = {(a,b), (b,y)} Intersection E ^ C = {(b,y)} Difference C - E = {(r,a), (r,b), (a,v), (a,w), (a,x), (b,z)} Inverseinv E = {(y,b)} Composition I o E = {(a,y)} Identity id = {(r,r), (a, a), (b,b), (w,w) … } Transitive Cl. C+ = {(r,a), (r, b), (r,v), (r,w), (r,x), (r,y), (r,z), (a,v), (a,w), (a,x), (b,y), (b,z)} Reflex. T.C. C* = id + C+
External Representation of Graphs RSF call P Q include F G store Q X contain Main P Main contain P F call Q include store G X
T a c d S e V b f g h Hide transformations Graph G d T e a V f b Graph I = hideExt(G, S) Graph H = hide(hide(G,T),V)
Hide transformation The hidetransformation takes a graph G that includes a hierarchical (tree) containment relation C and another relation R and a particular node S, and eliminates all descendent nodes of S, while replacing each edge from outside S to inside S by an edge to S, and each edge from inside S to outside S by an edge from S. Similarly for hideExt.
When use hide transformation? Use hide when relation R is “optimistically transitive”. T a c d S e V b f g h
Edged induced by hiding T a c d S e V b f g h Edges induced by edge (f,g) = all edges that hide/hideExt may cause to be drawn = all subpaths from f to g.
Family relations Given containment (child) relation C: Parent P = inv C Sibling S = P o C - id Descendent D = C+ Inclusive descendent Do = C* Ancestor A = P+ Inclusive ancestor Ao = P* Super cousin K = P* o S o C*
Induced cousins Given relation U (for “use”), what “higher level” relations are induced by U? Divide U into Uk (cousin edges) Ud (descendent/export/public edges) Ua (ancestor/buy edges) Induced cousin usage: Uk’ = (Do o Uk o Ao) ^ K Uk’ Do Ao Uk
Induced descendent edges (export/public edges) Ud’ = (Ao o Ud o Ao) ^ D + (K o Uk o Ao) ^ D Uk’ Ao K Ud Ao Ud’ Uk Ao Not Uk’ Ao Ud K Ao Not Ud’ Uk Ao
Grok: a relational calculator Program: getdb call.rsf tcall := call+ putdb both.rsf Input from call.rsf: call P Q call Q R Output to both.rsf: call P Q call Q R tcall P Q tcall Q R tcall P R P call Q call R
Inducing calls up to file level “call” is a procedure call “fcall” is a file level call File File fcall main.c start.h funcdef funcdcl main startup call Procedure body Procedure header fcall := funcdef o call o inv funcdcl
R b T y a S R T c S d R x Algorithms for composition and other operators Implement T := R o S Naïve implementation, O(e**2) = O(n**4) Original a R b b S c c R x y R d x S b Result a T c c T b for i : 1 .. e if type(i) = “R” then for j : 1 .. e if type(j) = “ S” & trg(i) = src (j) then create T(src(i), trg(j)) end if end for end if end for Remove duplicates
Algorithm: Isolate R edges, sort these by trg Isolate S edges, sort these by src Effectively merge these 2 lists Assuming linear sort (radix sort), time is O(e). Sorted edges a R b b S c y R d x S b c R x … ... R Result a T c c T b b T y a S R T c S d R x Algorithms for composition and other operators