Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Timna: A Framework for Automatically Combining Aspect Mining Analyses David Shepherd 1 Jeffrey Palm 2 Lori Pollock 1 Mark Chu-Carroll 3 1 University.

Similar presentations


Presentation on theme: "1 Timna: A Framework for Automatically Combining Aspect Mining Analyses David Shepherd 1 Jeffrey Palm 2 Lori Pollock 1 Mark Chu-Carroll 3 1 University."— Presentation transcript:

1 1 Timna: A Framework for Automatically Combining Aspect Mining Analyses David Shepherd 1 Jeffrey Palm 2 Lori Pollock 1 Mark Chu-Carroll 3 1 University of Delaware 2 Northeastern University 3 IBM

2 2 Introduction - What is AOP? Aspect Oriented Programming Each rectangle represents a source file Red lines represent source code lines implementing concept A figures from aspectj.com Language Support for Crosscutting Concerns (CCCs)

3 3 Introduction - A Closer Look at AOP Benefits of Refactoring into AOP Increased "ilities" –readability –maintainability –extensibility Crosscutting concerns (CCCs) are explicit aspect DisplayUpdating { after(): call(void Line.setP1(Point)) || call(void Line.setP2(Point)) { Display.update(); } class Line { private Point p1, p2; Point getP1() { return p1; } Point getP2() { return p2; } void setP1(Point p1) { this.p1 = p1; } void setP2(Point p2) { this.p2 = p2; } figures from aspectj.com Display.update(); Responsibility of AOP Community

4 4 Working Assumptions 1.AOP can provide benefits in modularity for some problems 2.Crosscutting Concerns are dangerous; awareness is essential

5 5 Targeted Problem: Mining Legacy Applications –refactor into AOP figures generated by the AJDT Aspect Mining is the process of finding these candidates

6 6 Targeted Problem: Mining 3 different programmers implement 1 concept Applications written with AOP, still problems...

7 7 State of the Art Researchers currently create a single analysis to perform aspect mining Examples Fan-in Analysis [Marin et al, WCRE 05] Code Clone Analysis [Shepherd et al, SERP 05] Dynamic Analysis [Breu et al, ASE 04]... Little work done on combining analysis

8 8 State of the Art Fan-In public void credit(float amount) { AccessController.checkPermission( new BankingPermission("accountOperation")); _balance = _balance + amount; } public void debit(float amount) throws InsufficientBalanceException { AccessController.checkPermission( new BankingPermission("accountOperation")); if (_balance < amount) { throw new InsufficientBalanceException("Insufficient total balance"); } else { _balance = _balance - amount; } checkPermission Good Candidate for Refactoring public void checkOut(SpecialList items) { SpecialIterator it = items.iterator(); while(it.hasNext()) checkOut(it.next()); } public void markItems(SpecialList items) { SpecialIterator it = items.iterator(); while(it.hasNext()) ((Item)it.next()).mark(); } next Bad Candidate for Refactoring [Marin et al, WCRE 04]

9 9 State of the Art Clone Detection public void debit(float amount) throws InsufficientBalanceException { UserTransaction ut =...; try { ut.begin();... business logic... ut.commit() } catch (Exception ex) { ut.rollback(); // rethrow after logging and wrapping } Conventional Transaction Management public void credit(float amount) { UserTransaction ut =...; try { ut.begin();... business logic... ut.commit() } catch (Exception ex) { ut.rollback(); // rethrow after logging and wrapping } [Shepherd et al, SERP 05]

10 10 Remaining Challenges Combining Analyses –if (code clone & fan-in high), more likely to be a refactoring candidate Running a large number of analyses –Methods with void return types –Getters and setters –... Our framework (Timna) combines analyses to make a decision We invented several new analyses, use 11 total analyses Humans do this during manual mining

11 11 Key Insight Currently, humans are the best miners. What is their process? 1.Manual Inspection 2. Learn to identify candidates in specific system 3. Generalize to other systems 4. Apply in other systems

12 12 Automated Approach 1.Create Training Data 1.Manual Tag Known Program 2.Automatically Run Individual Mining Analyses 2.Learn Output: set of rules to classify boolean or categories 3.Classify Unknown programs Output: refactoring candidates

13 13 Create Training Data Approach - Learning Known Program Manual Tagging Method AClass 2 Method BClass 1 Method CClass 1 Method DClass 3 Fan-in No Parameters Code Clone Pairings Method AAttributesClass 2 Method BAttributesClass 1 Method CAttributesClass 1 Method DAttributesClass 3 Machine Learning Classification Rules Classification Table Augmented Classification Table Mining Analyses 1.Create Training Data 2.Learn 3.Apply Method IdentifierAttributesClassification toolDone{?, ?, ?}refactor setTool{?, ?, ? }don't refactor exit{?, ?, ?}don't refactor Start{?, ?, ?}refactor Learn Rules

14 14 Create Training Data Learn Rules Approach - Learning Program Manual Tagging Method AClass 2 Method BClass 1 Method CClass 1 Method DClass 3 Fan-in No Parameters Code Clone Pairings Method AAttributesClass 2 Method BAttributesClass 1 Method CAttributesClass 1 Method DAttributesClass 3 Machine Learning Classification Rules Classification Table Augmented Classification Table Mining Analyses 1.Create Training Data 2.Learn 3.Apply 1.If( Fan-in > 5 and is-Void = true ), then (refactor) 2.If ( true ), then (don't refactor) Method IdentifierAttributesClassification toolDone{6, false, 3}refactor setTool{1, true, 1 }don't refactor exit{0, false, 2}don't refactor Start{4, false, 2}refactor Final Result: Only output to Classifying Phase

15 15 Unknown Program Approach - Classifying Method A Method B Method C Method D Fan-in No Parameters Code Clone Pairings Method AAttributes Method BAttributes Method CAttributes Method DAttributes Classifier Method AAttributesClass 2 Method BAttributesClass 1 Method CAttributesClass 1 Method DAttributesClass 3 Classification Table Mining Analyses Augmented Classification Table Completed Classification Table Classify Unknown Program Method IdentifierAttributesClassification showPrompt{6, false, 3}refactor takeOrder{1, true, 1 }don't refactor sendMessage{0, false, 2}don't refactor end{4, false, 2}refactor Classification Rules Method IdentifierAttributesClassification showPrompt{6, false, 3} takeOrder{1, true, 1 } sendMessage{0, false, 2} end{4, false, 2} Method IdentifierAttributesClassification showPrompt{} takeOrder{} sendMessage{} end{}

16 16 Evaluation Questions 1.Does combining analyses increase precision and recall? 2.Are generated rules effective on other programs? 3.Does categorical tagging increase performance? 4.What is the (time) overhead? 5.Can rules help direct research and evaluate new analyses? Tagged in two different ways: Boolean: either refactor or don't Categorical: either don't refactor or a reason (category) why to refactor

17 17 Experimental Setup Subject Programs Training Program (JHotDraw, 11K LOC) Testing Program (PetStore, 9K LOC) Steps 1.Train 2.Test on Training Program 3.Test on Testing Program Metrics Precision and Recall Time

18 18 Experimental Results Program not tagged, so can't calculate recall Timna: Cat Timna: Bool Timna: Cat Timna: Bool Precision = (number of good candidates returned) / (number of candidates returned) Recall = (number of candidates returned) / (number of actual good candidates)

19 19 Experimental Results 1.Does combining analyses increase precision and recall? Timna: Cat Timna: Bool Timna: Cat Timna: Bool Why is Fan-In performing poorly? Single analyses work well for specific cases, but fail to find all aspects. In this case, combining analyses does increase precision and recall.

20 20 Experimental Results 2. Are generated rules effective on other programs? Timna: Cat Timna: Bool Timna: Cat Timna: Bool In this case, the rules effectively mine from the testing program.

21 21 Experimental Results 3. Does categorical tagging increase performance? Timna: Cat Timna: Bool Timna: Cat Timna: Bool In this case, the categorical tagging and the boolean tagging perform similarly.

22 22 Experimental Results 4. What is the (time) overhead? Can be done incrementally, at each compile/edit, or overnight Only done once Can be done incrementally, at each compile/edit, or overnight Timna: Cat Timna: Bool Timna: Cat Timna: Bool From these results, we believe Timna could be integrated into an IDE without degrading response time. 6.24s 1.88s -- 5m28s 2m04s AnalyzeLearn

23 23 Experimental Results 5. Can rules help direct research and evaluate new analyses? [WARE 05] elaborates on use in evaluating new analyses if analyses does not appear in rules, it is providing no new information Human readable rules can help define style

24 24 Contributions Technique to combine mining analyses to automatically identify refactoring candidates Demonstrated how to apply machine learning to learn good AOP style from canonical examples –generate human readable rules Invented several (7) novel mining analyses during our initial use of Timna Experimentally shown evidence that combining analyses can improve performance

25 25 Possible Application Implicit Rule: Always create UndoActivity before "executing" undoable Implicit Rule: Check damage after changing drawing Possible Rule: Clear Selection before changing drawing Of course! Whenever I change something in the drawing, I should check to see if I damaged the drawing. Moving this concept to an aspect can eliminate a lot of similar calls from my OOP code. Provide hints, shaded by level of confidence AOSD-style programming with reduced costs and burdens on the developer

26 26 Future Work Examine other aspect categorization –"Sorts" (Marin et al, ICSM 05) Extend with additional analyses –NLP-based analyses Apply to more unknown programs


Download ppt "1 Timna: A Framework for Automatically Combining Aspect Mining Analyses David Shepherd 1 Jeffrey Palm 2 Lori Pollock 1 Mark Chu-Carroll 3 1 University."

Similar presentations


Ads by Google