Dyamic Aalysis ad Desig Patter Detectio i Java Programs Outlie Lei Hu Kamra Sartipi {hul4, sartipi}@mcmasterca Departmet of Computig ad Software McMaster Uiversity Caada Motivatio Research Problem Defiitio ad Solutio Proposed Framework for Feature-Orieted Desig Patter Detectio Feature-orieted Dyamic Aalysis Two-phase Desig Patter Detectio Process Case studies o Three Versios of JHotDraw s Cotributio SEKE 08 July 3, 2008 1 2 Motivatio Research Defiitio Software product lie is a group of software-itesive systems that share a commo set of features to satisfy the specific eeds from the market Developed based o a referece architecture which cosists of commo parts ad variable parts A evolutioary developmet of a software product lie starts from reverse egieerig activities Uderstadig the existig systems Locatig commo features to reuse Desig patter recovery ca support the costructio of software product lie Uderstadig the existig system at desig level Reusig the existig system s desig artefacts Research Ageda: To devise a methodology ad supportig tools for recoverig the istaces of desig patters from the implemetatio of software system s behavioural features, by the meas of a high level patter descriptio method Provided Solutio: We propose a reverse egieerig framework which combies feature-orieted dyamic aalysis with two-phase desig patter detectio techique to idetify the istaces of desig patters for differet software behavioural features 3 4 Foudatio of Reverse Egieerig Reverse Egieerig A process of aalyzig a software system to idetify a system s compoets ad their iterrelatioships, ad create represetatio of the system at a higher level of abstractio [Chikofsky&Cross ] Two major sub-areas i Reverse Egieerig Static Aalysis Clusterig Visualizatio Patter Matchig (Desig Patter Recovery) Dyamic Aalysis Feature idetificatio Behavioural desig model extractio Proposed Framework for Feature-orieted Desig Patter Detectio 5 6
(Dyamic Aalysis) Feature-orieted Dyamic Aalysis Elicit commo features of existig systems A group of similar systems i a domai 1 2 3 Subject (Static Aalysis) Two-phase Desig Patter Detectio Process Desig Patter Repository Obtai iter-class relatios by parsig the Subject features For each commo feature, geerate a set of featurespecific scearios for Subject Group of sceario sets Execute sceario sets o the istrumeted Subject to geerate executio traces Relatio matrices Approximate matchig usig class relatio cardiality Use cocept lattice to separate commo classes form feature specific classes Executio Patters Specific features f1 f2 Executio traces Extract executio patters usig sequetial patter miig Feature-specific classes Structural matchig usig iter-class relatios Source-class cluster Target patter from Repository Idetified Target patter istaces Dyamic Aalysis Feature-Orieted Dyamic Aalysis f3 f4 f5 Mappig betwee features ad feature-specific classes Correlate features with idetified desig patter istaces Mappig betwee features ad desig patter istaces 7 8 Feature-Orieted Dyamic Aalysis ----Executio Traces Geeratio Usig Eclipse Test ad Performace Tools Tools Platform Platform (TPTP) (TPTP) to collect to collect the executio the executio trac traces geerated geerated by ruig by ruig the scearios the scearios i the feature-specific i the feature-specific sceario set sceario set Reducig executio trace size usig filter set mechaism Feature-Specific Sceario Set - Start, Draw a Ellipse, move, Exit - Start, Draw a Lie, move, Exit - Start, Draw a Rectagle, move, Exit - - Start, Draw a Polygo, move, Exit TPTP O Eclipse Ruig the system i a profilig mode Executio traces Eter CH/ifa/draw/stadard/AbstractHadle Leave CH/ifa/draw/stadard/AbstractHadle Eter CH/ifa/draw/stadard/RelativeLocator Eter CH/ifa/draw/figures/RectagleFigure Leave CH/ifa/draw/figures/RectagleFigure Leave CH/ifa/draw/stadard/LocatorHadle Leave CH/ifa/draw/stadard/AbstractHadle Feature-Orieted Dyamic Aalysis ----Executio Patter Extractio Feature 1 Feature 2 Feature 3, C4, C3, C8, C4, 5, C2, C3, C8, 6, 5, C5, C3, C8, C4, 0, 8, C20, C7, C3, C8, C20, 3, 5, C4, C3, C8, C9, 5, C3, C8, C4, 0, 7, 8, C20, C3, C8, C4, 0, 8, C20 feature 1 2 3 Executio Patters Executio Traces for 3 Feature-specific Sceario Sets 5 C4, 0 8, C20, C4, C23, C28, C20, C2, C23, C28, 5, C5, C23, C28, C4, 0, 8, C20, C7, C23, C28, C20, 3, 5, C4, C23, C28, C9,, C4, 0, 5, C23, C28, C4, 0, 7, 8, C20 5 C4, 0 8, C20 5, C4, C33, C38, C4, 5, C2, C33, C38, 6, 5, C5, C33, C38, 5, C7, C33, C38, C20, 3, 5, C4, C33, C38, C9, 5, C9, C33, C38, 0, 5 Commo patter Noise patter Apply Sequetial Patter Miig to geerate Executio Patters 9 C3, C8 C23, C28 C33, C38 Feature-specific patter 10 Static Aalysis Two-Phase Desig Patter Detectio 11 Depth2-SubClass1 Describe Desig Patter usig PDL Differet types of the classes i PDL Mai-seed class, Depth1 class, Depth2 class ad Seed-depth1 class Example: Class diagram of a target desig patter Depth1-AssoClass Depth1-Subclass1 Depth1-SuperClass1 MaiSeedClass Depth1-Subclass1 PDL Represetatio of a target desig patter 1 Begi-PDL 2 Patter: TargetPatter 3 Mai-seed class: MaiSeedClass 4 Depth1: 5 Iherit_From: 6 Depth1-SuperClass1 7 Iherited_By: 8 Depth1-SubClass1; 9 Depth1-SubClass2 10 i_associatio: 11 Depth1-AssoClass 12 Depth2: 13 Seed-Depth1 : Depth1-AssoClass 14 Iherited_By: 15 Depth2-SubClass1 16 Ed-Patter 17 Ed-PDL 12
Two-phase Desig Patter Detectio Process Two-phase Desig Patter Detectio ----Approximate Matchig Subject Obtai iter-class relatios by parsig the Subject Structural Matchig Relatio matrices Depth1Matchig Approximate Matchig Depth1Matchig a list of sourceclass clusters Set of all combiatios of matched source-classes of all depth1-classes Desig Patter Repository Attribute Vector The attribute vector icludes the followig items: Number of Iherit _From / Iherited_By relatio Number of i _Associatio / out _Associatio relatio Number of isabstract relatio (0 or 1) Similarity Fuctio Give the attribute vector of the mai-seed class ad the attribute vector of ad a source-class, the approximate similarity fuctio is defied as: Depth2Matchig Set of all combiatios of matched source-classes of all depth2-classes Merge Depth1 combiatio ad Depth2 combiatio Idetified desig patter istaces 13 Result: a group of source-class clusters Two-phase Desig Patter Detectio ----Structural Matchig Idetifyig all the istaces of the target desig patter withi a source-class cluster A Example Class diagram of Bridge Desig Patter PDL represetatio of Bridge Desig Patter Depth1Matchig Iput: a source-class cluster, a cadidate mai-seed class, ad a target desig patter Output: set of all combiatios of matched source-classes of all the depth1-classes Depth2Matchig Iput: a source-class cluster, a combiatio of matched source-classes of all the depth1-classes ad a target desig patter Output: set of istaces of the target desig patter 15 Abstractio Implemetor RefiedAbstractio CocreteImplemetorA CocreteImplemetorB Attribute Vector Attr_Vec (Implemetor) = [0, 2, 1, 0, 1] 1 Begi-PDL 2 Patter: Bridge 3 Mai-seed class: Implemetor 4 Depth1: 5 Iherited_By: 6 CocreteImplemetorA; 7 CocreteImplemetorB 8 i_associatio: 9 Abstractio 10 Depth2: 11 Seed-Depth1 : Abstractio 12 Iherited_By: 13 RefiedAbstractio 14 AbstractClass: 15 Implemetor; 16 Abstractio 17 Ed-Patter 16 18 Ed-PDL A Example A Example Search Space Depth1Matchig Class diagram of Bridge Desig Patter A source-class cluster Abstractio Implemetor RefiedAbstractio CocreteImplemetorA CocreteImplemetorB Through applyig approximate matchig o the search space, we obtai two cadidates of mai-seed class C2 ad C3 Attr_Vec(C2)=[1, 2, 1, 1, 1] Attr_Vec(C3)=[1, 2, 1, 1, 1] Attr_Vec (Implemetor) = [0, 2, 1, 0, 1] 17 18
Experimets with JHotDraw Statistics of three versios of JHotDraw systems Experimets with JHotDraw Cocept lattice represetatio of features ad classes i JHotDraw 51 The experimetal results of executio patter extractio Leged : A / B / C A: data for JHotDraw 51 B: data for JHotDraw 60b1 C: data for JHotDraw 707 19 20 Experimets with JHotDraw Results of feature-specific classes assigmet for 10 features of JHotDraw 51 Experimets with JHotDraw Results of idetified Adapter desig patter istaces ad related features i JHotDraw 51 system 21 The Executio Trace for sceario Drawig ad Flippig Rectagle is Aotated with Descriptios of Executio Patters 22 Summary We preseted: A methodology to idetify idividual desig patter istaces from the implemetatio of system behavioural features A ew desig patter represetatio, PDL (Patter Descriptio Laguage), which eables users to describe the structural iformatio of desig patters efficietly ad coveietly A two-phase desig patter process (approximate matchig & structure matchig) to reduce the complexity of the matchig process A prototype toolkit for the proposed approach o the Eclipse ope platform Future Work Our future work will maily cocetrate o the followig directios: Extedig the patter repository to support more desig patters idetificatio Extractig more iter-class relatios, such as delegatio ad method ivocatio, to improve the accuracy of the techique Validatig our approach o large-scale software systems Trackig the evolutio of software systems at desig level by aalyzig the evolutio of desig patters 23 24
Dyamic Aalysis ad Desig Patter Detectio i Java Programs Lei Hu Kamra Sartipi {hul4, sartipi}@mcmasterca Departmet of Computig ad Software McMaster Uiversity Caada SEKE 08 July 3, 2008 25