towards supporting on-demand virtual remodularization using program graphs david shepherd, lori...

46
Towards Supporting On- Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay- Shanker University of Delaware

Upload: cuthbert-floyd

Post on 31-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Towards Supporting On-Demand Virtual

Remodularization Using Program Graphs

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

University of Delaware

Page 2: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Overview and Rationale

on-demandremodularization

//Activates the tool for the given view. //Turn on dragtool by adding....

activate tool

save drawing

update drawing

undo action

object oriented systemaction

oriented system

public void Tool.activate()

Page 3: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Overview and Rationale

public interface Storable{...

activate tool

save drawing

update drawing

undo action

public void Circle.save()

//Store the fields in a file....

action oriented system

object oriented system

Key Insight: Programmers leave natural language clues that

reference concerns

Page 4: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

State of the Art in Feature Location/Aspect Mining

• Dynamic Information – [Wilde ICSM 00], [Michail ICSE 02], [Zhao ICSE

04], [Breu ASE 04], [Ceccato ICSM 05]...

• Program Structure– FEAT, [Sextant ICSM 05], [Robillard FSE 05]...

• Information Retrieval– [Marcus PhDThesis 03], [ICSE 03]

• Lexical Information– [Aspect Mining Tool], [Aspect Browser]

Foundations

Low-level Clues

Complementary

Page 5: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

A Motivating Example

Recipe for Vegetable Soup

1. Place asparagus and onion in a saucepan with 1/2 cup vegetable broth. Bring the broth to a boil, reduce heat and let simmer until the vegetables are tender.

2. Reserve a few asparagus tips for garnish. Place remaining vegetable mixture in an electric ...

Recipe Writing Factory

Procedural instructions are easy to read

Page 6: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Recipe Writing System 1.0Choosing a Dominant Decomposition

Page 7: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

asparagus • Place asparagus in a saucepan.• Reserve a few asparagus tips for

garnish• Garnish with reserved asparagus

tips.

flour

• Sprinkle flour into the butter. Do not let the flour brown.

butter

• Melt butter in the pan that was used for simmering the asparagus and onions…stir.

salt

• Sprinkle salt into the butter.

soy milk

• Stir the milk into the saucepan.

yogurt

• Whisk yogurt into the mixture

OO decomposition provides many benefits

Recipe Writing System 1.0Choosing a Dominant Decomposition

Page 8: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Action-Oriented CCCs Appear

asparagus • Place asparagus in a saucepan.• Reserve a few asparagus tips for

garnish• Garnish with reserved asparagus

tips.

flour

• Sprinkle flour into the butter. Do not let the flour brown.

butter

• Melt butter in the pan that was used for simmering the asparagus and onions…stir.

salt

• Sprinkle salt into the butter.

onion

• Place onion in the saucepan

yogurt

• Whisk yogurt into the mixture

OOP causes scattered actions

Page 9: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Evolution Causes Scattered Actions

Beef

place(p)checkIfFitsInPan(p)actuallyPlaceInPan(

p)

//Place the Beef into the panplace(Pan p){ checkIfFitsInPan(p); actuallyPlaceInPan(p);}

//Make sure the beef fits in the pan,//before Placing the Beef into the pancheckIfItFitsInPan(Pan p){ ...}

//Place the beef into the panactuallyPlaceInPan(Pan p){ ...}

Evolution causes more scattered actions

Page 10: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Maintenance Tasks Involve Scattered Actions

Something goes wrong when I place ingredients in the

saucepan.

Maintenance tasks require action location

Page 11: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

How can we find actions in a noun's world?

Our Strategy1. Extract natural language clues2. Query clues and remodularize

Page 12: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Extract Clues with NLP

//Place the beef into the panBeef.place(Pan p){ checkIfFitsInPan(p); actuallyPlaceInPan(p);}

//Make sure the beef fits in the pan,//before placing the beef into the panBeef.checkIfItFitsInPan(Pan p){ ...}

//Place the beef into the panBeef.actuallyPlaceInPan(Pan p){ ...}

//Place the onion in the panOnion.place(Pan p){ ...}

place onion

place beef

place beef, check beef

place beef

//Make sure the beef fits in the pan,//before placing the beef into the panBeef.checkIfItFitsInPan(Pan p){ ...}

//Place the beef into the panBeef.place(Pan p){ checkIfFitsInPan(p); actuallyPlaceInPan(p);}

//Place the beef into the panBeef.actuallyPlaceInPan(Pan p){ ...}

Key Insight: Use language clues to extract actions

Page 13: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Query Clues and Remodularize

//Place the beef into the panBeef.place(Pan p){ checkIfFitsInPan(p); actuallyPlaceInPan(p);}

//Make sure the beef fits in the pan,//before placing the beef into the panBeef.checkIfItFitsInPan(Pan p){ ...}

//Place the beef into the panBeef.actuallyPlaceInPan(Pan p){ ...}

//Place the onion in the panOnion.place(Pan p){ ...}

simple query: place

Virtual Source File

From OO code to Action-Oriented code!

Page 14: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

A Closer Look at the Extraction Process...

Page 15: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

What to Extract

• information about actions– verbs– direct-objects

ex: Place the item in the panex2: Place the beef in the pan

Something goes wrong when I

place ingredients into the saucepan.

Something goes wrong when I

place beef into the saucepan.

Our Strategy: extract verb and direct object pairs

Page 16: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

How to extract clues

Two types of extraction

class Beef{

//Chop the beef into cubes. chop(){ unwrap(); slice(CUBES); }

}

Extraction from comments

Extraction from method signatures

Page 17: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Extracting Clues from Comments

1. Part-of-speech tagging2. Chunking3. Role assignment

Remove an item from a cartRemove<v> an<dt> item<n> from<p> a<dt>

cart<n>Remove<v> [an item]<noun phrase>

[from [a cart] <noun phrase>] <prepositional phrase>

rule: when a verb is followed by a noun phrase, extract

Remove item

Page 18: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Extracting Clues from Signatures

1. Process method name2. Use hierarchy of rules to classify3. Use classification to extract

class Beef{ //Chop the beef into cubes. chop(){ unwrap(); slice(CUBES); }}

Page 19: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Extracting Clues from Signatures

1. Process method name2. Use hierarchy of rules to classify3. Use classification to extract

class Beef{ //Chop the beef into cubes. chop(){ unwrap(); slice(CUBES); }}

chop<v> [the beef]<noun

phrase>

chop<

v>

Page 20: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

1. Process method name2. Use hierarchy of rules to classify3. Use classification to extract

class Beef{ //Chop the beef into cubes. chop(){ unwrap(); slice(CUBES); }}

Example Classification: method has no parameters and the method name is a verb

chop<

v>

Extracting Clues from SignaturesHand Tuned

Rule Tree

Page 21: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

1. Process method name2. Use hierarchy of rules to classify3. Use classification to extract

class Beef{ //Chop the beef into cubes. chop(){ unwrap(); slice(CUBES); }}

Example Extraction Rule:

•get verb from method name

•get DO from class namechop beef

Extracting Clues from Signatures

Page 22: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Storing the Clues

Action-Oriented Identifier Graph (AOIG)

verb1 verb2 verb3 DO1 DO2 DO3

verb1, DO1 verb1, DO2 verb3, DO2 verb2, DO3

source code files

use

use

use

use

use

use

useuse

Page 23: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Action-Oriented Identifier Graph (AOIG)

chop grill puree onion beets steak

chop, onion chop, beets puree, beets grill, steak

source code files

use

use

use

use

use

use

useuse

Storing the Clues

Page 24: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Survey of AOIG-Builder's Accuracy How Accurate is Extraction?

Category No. of Verb-DO Pairs

No. of Verb-DO Pairs

Declarations

Comments

correct 50 43

incorrect 4 1

omitted 2 11

total 57 55

Good Precision and Recall

Avg. Precision

95%

Avg. Recall

83%

Page 25: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Costs of Building the AOIGper source file

• Space– O(number of methods)– minimal

• Time– O(number of methods)– 10 seconds for a large source file with

lots of multi-line comments

Reasonable cost - can be done incrementally

Page 26: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Contributions...

Page 27: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Action-Oriented View

• High-level CCCs instead of low-level– clear hypothesis of why actions are

CCCs

• Useful type of CCC– maintainers are looking for actions

Page 28: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Contributions (continued)

• Action-Oriented View• Combined NLP+Program Analysis

(NLPA)• Developed the AOIG for virtual

remodularization• Applied AOIG to

– Feature Location*– Aspect Mining– Working Set Recovery

Page 29: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Questions?

activ

ate

tool

save d

raw

ing

up

date

dra

win

g

un

do a

ction

object oriented systemaction

oriented system

Page 30: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Conclusions

• NLP– is sufficiently robust to use in SE tools

• NLP + Program Analysis– can extract more exact information from

code– can drive SE tools

We have shown how to virtually remodularize code into actions using the AOIG

Page 31: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Demo of Current/Future Work

• Complete Feature Location Methodology– sophisticated query expansion– action-oriented code view for program

understanding

Page 32: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Current/Future Work

Page 33: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

generate

Page 34: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware
Page 35: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware
Page 36: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware
Page 37: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware
Page 38: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware
Page 39: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

PowerGrid.timePassing()

PowerGrid.powerSurplusPowerGeneration.constructor

PowerGeneration.getGeneratedPower()

PowerSource.getCurrentPower()calls

SolarPowerSource.getCurrentPower()

PowerSource.getCurrentPower()

StandardPowerSource.getCurrentPower()

Page 40: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Experiments

• Subjects: QLI projects• Procedure:

1. Identify bugs or feature requests which require action location

2. Use tool to locate and squash bugs

For submission to ICSM Industry Track

Page 41: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

User FeedbackDIRECTIONS:1. Place asparagus and onion in a saucepan with 1/2 cup vegetable broth. Bring

the broth to a boil, reduce heat and let simmer until the vegetables are tender. 2. Reserve a few asparagus tips for garnish. Place remaining vegetable mixture in

an electric blender and puree until smooth. 3. Melt butter in the pan that was used for simmering the asparagus and onions.

Stir while sprinkling flour, salt, and pepper into the butter. Do not let the flour brown. Allow the mixture to cook only 2 minutes. Stir in remaining 1 1/4 cups vegetable broth and increase the heat. Continue stirring until the mixture comes to a boil.

4. Stir the vegetable puree and milk into the saucepan. Whisk yogurt into the mixture, followed by lemon juice. Stir until heated through, then ladle into bowls. Garnish with reserved asparagus tips. Sprinkle with Parmesan cheese if desired.

Something goes wrong when I am

sprinkling things into the butter.

Page 42: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Recipe Developer, Fix it

Page 43: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Recipe Storage System: 2.0

Person

place(List ingredients, Pan p)

Placeable

place(Pan p)

Vegetable

place(Pan p)

Beef

place(Pan p)

Pepper

place(Pan p)

Onion

place(Pan p)

more complex system, actions are scattered further

Page 44: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Clever Worker1 pound fresh asparagus

1. Place asparagus in a saucepan.

2. Reserve a few asparagus tips for garnish

3. Garnish with reserved asparagus tips.

2 tablespoons all-purpose flour

1.2.3. Sprinkle flour into the butter.

Do not let the flour brown.

1 tablespoons butter

1.2.3. Melt butter in the pan that was

used for simmering the asparagus and onions…stir.

1 teaspoon salt

1.2.3. Sprinkle salt into the butter.

1 cup soy milk

12.3. Stir the milk into the saucepan.

1/2 cup yogurt

1.2.3.4. Whisk yogurt into the mixture

Page 45: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Person

sprinkleItems(List ingredients)

Page 46: Towards Supporting On-Demand Virtual Remodularization Using Program Graphs David Shepherd, Lori Pollock, and K. Vijay-Shanker University of Delaware

Clever Worker1 pound fresh asparagus

1. Place asparagus in a saucepan.

2. Reserve a few asparagus tips for garnish

3. Garnish with reserved asparagus tips.

2 tablespoons all-purpose flour

1.2.3. Sprinkle flour into the butter.

Do not let the flour brown.

1 tablespoons butter

1.2.3. Melt butter in the pan that was

used for simmering the asparagus and onions…stir.

1 teaspoon salt

1.2.3. Sprinkle salt into the butter.

1 cup soy milk

12.3. Stir the milk into the saucepan.

1/2 cup yogurt

1.2.3.4. Whisk yogurt into the mixture