1 Structural Manipulations of Software Architecture Using Tarski Relational Algebra Ric Holt University of Waterloo, Canada Paper at WCRE '98: Working Conference on Reverse Engineering, Honolulu, Oct 1998.
2 Top view of concrete software architecture of 250KLOC system
3 Client-server view of one subsystem of the 250KLOC system
4 Process of view creation Parser Grok: Fact manipulator Layouter Browser Clustering Source code Facts extracted from code Hierarchic decomposition Architectural diagram
5 Example typed graph r ab C C vwxyz CCCECC I UU v w xy z ab r U U I E 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) }
6 Algebraic Operators UnionI + E = {(a,b), (b,y)} IntersectionE ^ C = {(b,y)} DifferenceC - E = {(r,a), (r,b), (a,v), (a,w), (a,x), (b,z)} Inverseinv E = {(y,b)} CompositionI o E = {(a,y)} Identityid = {(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+
7 External Representation of Graphs RSF call P Q include F G store Q X contain Main P P Q X call Main contain store F G include
8 Hide transformations a b c d e f g h T V S b a T V Graph G Graph H = hide(hide(G,T),V) d e f Graph I = hideExt(G, S)
9 Hide transformation The hide transformation 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.
10 When use hide transformation? Use hide when relation R is “optimistically transitive”. a b c f g h T V S e d
11 Edged induced by hiding a b c d e f g h T V S Edges induced by edge (f,g) = all edges that hide/hideExt may cause to be drawn = all subpaths from f to g.
12 Family relations Given containment (child) relation C: ParentP = inv C SiblingS = P o C - id DescendentD = C+ Inclusive descendentDo = C* AncestorA = P+ Inclusive ancestorAo = P* Super cousinK = P* o S o C*
13 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 DoAo Uk Uk’
14 Induced descendent edges (export/public edges) Ud’ = (Ao o Ud o Ao) ^ D + (K o Uk o Ao) ^ D Ud Ao Ud’ Ud Ao Not Ud’ K Uk Uk’ Ao K Uk Ao Not Uk’
15 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 Q R call
16 Inducing calls up to file level “call” is a procedure call “fcall” is a file level call fcall := funcdef o call o inv funcdcl main.c startup start.h main call funcdef funcdcl Procedure bodyProcedure header File fcall
17 Algorithms for composition and other operators Implement T := R o S Naïve implementation, O(e**2) = O(n**4) 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 Original a R b b S c c R x y R d x S b Result a T c c T b a b x c d y R S R S T R T
18 Algorithms for composition and other operators 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 …... Result a T c c T b a b x c d y R S R S T R T