18
1 Case Study: Supplementing Program Analysis with Natural Language Analysis to Improve a Reverse Engineering Task David Shepherd, Lori Pollock, and K. Vijay- Shanker University of Delaware

David Shepherd, Lori Pollock, and K. Vijay-Shanker

  • Upload
    jafari

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Case Study: Supplementing Program Analysis with Natural Language Analysis to Improve a Reverse Engineering Task. David Shepherd, Lori Pollock, and K. Vijay-Shanker. University of Delaware. Consider the Reverse Eng Task…. Aspect-Oriented Programming , language support for:. Aspect Mining. - PowerPoint PPT Presentation

Citation preview

Page 1: David Shepherd, Lori Pollock, and K. Vijay-Shanker

1

Case Study: Supplementing Program Analysis with Natural Language Analysis to Improve a Reverse Engineering Task

David Shepherd,

Lori Pollock, and K. Vijay-Shanker

University of Delaware

Page 2: David Shepherd, Lori Pollock, and K. Vijay-Shanker

2

Consider the Reverse Eng Task…

Aspect-Oriented Programming, language support for:

Aspect MiningLocates refactoring

candidates

Page 3: David Shepherd, Lori Pollock, and K. Vijay-Shanker

3

Classic Aspect Candidates

Before/After Aspects [Mastering AspectJ, Aspectj.com]

Certain Design Patterns [Hanneman 02]

Circle.setRadius(x){ r = x;

}Display.update()

Square.setSize(x){ size = x;

} Display.update()

Aspect Updater After Shape.set*()Call Display.update()

public MultiFigure(){ numFigs =n;….

}

addListener(Drawing)

public Square(y){ side = y;

}addListener(MultiFigure)

Aspect Listener After Figure.construct()Add parent as listener

Page 4: David Shepherd, Lori Pollock, and K. Vijay-Shanker

4

Current Aspect Mining Analyses

MethodDisplay.update()

Call Graph Fragment

Fan-In Analysis Code Clone Analysis[Marin et al. WCRE 2005] [Shepherd SERP 04, Bruntink ICSM 04]

Traditional Program Analyses (TPA) can be effective

Traditional Program Analyses (TPA)

Page 5: David Shepherd, Lori Pollock, and K. Vijay-Shanker

5

Consider Natural Language Analyses (NLA)

Scenario

Class: DrawApplication

MethodsaddViewChangeListener removeViewChangeListener

Opposite Verbs

Observer Word ComboNatural Language Analyses can be effective

Page 6: David Shepherd, Lori Pollock, and K. Vijay-Shanker

6

Quiz: Is TPA Enough?

Method

TextAreaTool.beginEdit()

Call Graph Fragments

Which method(s) are good candidates?

Method

Geom.length()A B

Traditional Program Analyses (TPA) can be misleading

Page 7: David Shepherd, Lori Pollock, and K. Vijay-Shanker

7

Quiz: Is NLA Enough?

Scenario A

Method uses verb “add”

Another method in the same class uses verb “remove”

Scenario B

Method uses verb “add”

Another method in the same class uses verb “remove”

List.add()Figure.addListener()Natural Language Analyses can be misleading

Page 8: David Shepherd, Lori Pollock, and K. Vijay-Shanker

8

Summary: TPA & NLA Complementary

Using NLA and TPA together to build a case for refactoring

Method

Auctions.startBlocking()

Fan-in is high

Opposite verb is usedCalled in a clone

Method

Auctions.endBlocking()Supplementing TPA with NLA makes a stronger case for refactoring

Page 9: David Shepherd, Lori Pollock, and K. Vijay-Shanker

9

Timna

Talk Progression

Aspect Mining Framework: Timna

Fan-in

Method signature

Code clone…

Integration of Natural Language in iTimna Evaluation

NLAiTimna

Page 10: David Shepherd, Lori Pollock, and K. Vijay-Shanker

10

Timna: An Aspect Mining Framework

Timna uses machine learning to combine analyses

Phase 1: Learning (occurs once)

TaggedProgram

MiningAnalyses

AnalysesResults

MiningRules

Learner

Phase 2: Classifying (occurs many times)

ProgramMining

AnalysesAnalysesResults

ClassiferMarkedProgram

Method name| Fan-in | Code Clone | Is VoidopenWindow 3 T TaddListener 7 F F

If( Fan-in >3 and Is-Void) then the method is a refactoring candidate

Page 11: David Shepherd, Lori Pollock, and K. Vijay-Shanker

11

iTimna: Adding NLA to Timna

ProgramAnalyses

DriverAnalysesResults

Add the NL Analyses here

TPAnalyses

Code clone Signature analysis Callsite pairings

NLAnalyses

Opposite verbs Observer words Constraint verbs

Page 12: David Shepherd, Lori Pollock, and K. Vijay-Shanker

12

An Example NLA

NLA: Past-Tense Verb Intuition: Past-Tense indicates reactionary Process:

1. Extract verb [AOSD 06]

2. Use morphological analysis to detect verb tense Examples:

figureSelectionChanged() setSelection drawingInvalidated()

changed past-tense set not past-tense

invalidated past-tense

Page 13: David Shepherd, Lori Pollock, and K. Vijay-Shanker

13

Evaluation

Question: What effect does integrating NLA with TPA have on AM?

Methodology: Manually tag a program, Use AM tools, Check results

Measures: Precision (quality) and Recall (completeness)

Subject Program: JHotDraw

AM Tools: Fan-in, Timna, iTimna

Tagger bias?

Overfitting?

Enough examples?

(2,739 methods)

Page 14: David Shepherd, Lori Pollock, and K. Vijay-Shanker

14

Quantitative Results

Fan-in Precision 37 Recall 2

Timna Precision 62 Recall 60

iTimna Precision 81 Recall 73

Page 15: David Shepherd, Lori Pollock, and K. Vijay-Shanker

15

Qualitative Results

NLA and Simple Program Information

If (Void Return Type & Opposite Verb & No Parameter)

Then the method is a candidate

Page 16: David Shepherd, Lori Pollock, and K. Vijay-Shanker

16

Qualitative Results

NLA and Simple Program Information

If (Not Void Return Type && Constraint Verb)

Then the method is a candidate

Page 17: David Shepherd, Lori Pollock, and K. Vijay-Shanker

17

Related Work

Mining Dynamic Information [Breu ASE 04, Ceccato WCRE 04]

Mining Static Information [Marin WCRE 04, Shepherd SERP 04, Bruntink ICSM 04]

Combining/Comparing Approaches Sorts [Marin WCRE 2006]

Qualitative Comparison [Tourwe IWPC 05]

Single Analyses

Simple Combinations

Recommend Combining

Page 18: David Shepherd, Lori Pollock, and K. Vijay-Shanker

18

Conclusions

Created NLAs for Aspect Mining Showed that TPA and NLA can work together Evaluated prototype, shows strong promise

Supplementing TPA with NLA improves the effectiveness of our aspect mining framework and warrants further

evaluation