210 likes | 368 Views
Efficient Identification of Design Patterns with Bit-vector Algorithm. Design recovery to maintain. Contents. Introduction Design recovery Bio-informatics Bit-vector algorithm Sample Algorithm Procedure Design Pattern - Composite Simple Program Structure Development Procedure 4 Step
E N D
Efficient Identification of DesignPatterns with Bit-vector Algorithm Design recovery to maintain
Contents • Introduction • Design recovery • Bio-informatics Bit-vector algorithm • Sample Algorithm Procedure • Design Pattern - Composite • Simple Program Structure • Development Procedure • 4 Step • Results • Conclusion
Introduction - Design Recovery Efficiently Maintain
Introduction - Bit Vector • The structure of DNA and RNA are very similar. They are both ordered sequences of 4 types of substances: ACGT for DNA, and ACGU for RNA. • ex) AAACGTTTCCGGAATGG • find TCC • DNA is string(ACGT). • For Searching "Matching DNA", use Bit Vector Algorithm. • Program source is string too. • We can use Bit Vector
Sample Algorithm Procedure - Composite 1. Pattern 2. Eulerian model 3. String
Sample Algorithm Procedure - Simple Program 1. Source 2. Eulerian model 3. String
Sample Algorithm Procedure - Searching 1 2 3 Component in Leaf dm Component in Composite co Component A in B in D dm B in E co B in C dm G cr C dm G cr D dm G cr E dm G as F ag A 3 [Find Composite Pattern] B = Component D = Leaf E = Composite 1 2
Sample Algorithm Procedure - Bit Vector If B == Component, Where is B A in B in D dm B in E co B in C dm G cr C dm G cr D dm G cr E dm G as F ag A 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >>B (double shift) 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We need "in" relation A in B in D dm B in E co B in C dm G cr C dm G cr D dm G cr E dm G as F ag A 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >in 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 If E = Composite, Where is E 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
Sample Algorithm Procedure - Bit Vector 2 (>>B) and (>in) and (E) = not null = (B in E) 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 and and 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 and 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 = 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 It is finish next 1 2 3 Component in Leaf dm Component in Composite co Component
Sample Algorithm Procedure - Bit Vector 3 It is finish next 1 2 3 Component in Leaf dm Component in Composite co Component 1 and 2 and 3 = not null A in B in D dm B in E co B in C dm G cr C dm G cr D dm G cr E dm G as F ag A
Development Procedure 1/4 • Model( Design patterns, Program ) • PADL meta-model • To describe design motifs and programs. • Defines all the constituents. • To describe design motifs and programs • behaviour, relationships, message sends. • Parsers to build models • AOL, C++, Java • Includes a design motif repository • Containing several well-known design patterns • such as Abstract Factory, Composite, Facade.
Development Procedure 2/4 • Eulerian Graph • Equal in-degree and out-degree • Need DM(Dummy) Edge • Park's implementation of the transportation simplex
Development Procedure 3/4 • String Representations • Thimbleby's efficient implementation of an algorithm to solve the Chinese Postman problem
Development Procedure 4/4 • Iterative bit-vector algorithm • In Java using the Eclipse platform. • We use a sparse vector(bit string) • majority of the bits in the vectors are 0 • Hash map and only the 1-valued bits are stored.
Results • Two Design Patterns • Abstract Factory • Composite • Three Programs • JHotDraw v5.1 • Juzzle v0.5 • QuickUML 2001 AMD Athlon 64bits at 2GHz.
Results 2 • Compare with other Approach • CP : explanation-based Constraint Programming • M : Matric-enhanced Bit Vector - Optimize
Result 3 • Optimize ?? {Component = B, Composite = E, Leaf = {C, D}} or {Component = B, Composite = E, Leaf = C} ∧ {Component = B, Composite = E, Leaf = D}. Leaf -> Leaves
Results 4 the use of metrics is interesting because it reduces the noise and could be combined with our bit-vector algorithm to increase precision and performance even more.
Conclusion • We presented an adaptation of bio-informatics bitvector algorithms to the software maintenance problem of design pattern identification. • We implemented our approach and showed its efficiency on three small-to-medium size programs and the quality of its results, including its approximation capabilities. • Some design patterns also specify what must not be found. For example, the Adaptee role in the Adapter design motif must not know the Adapter role. • As future work • string representation -> Build automatically. • string representation -> Search their emplacements in the program.