StarCharter: A Tool for Mining Concept Recipes

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "StarCharter: A Tool for Mining Concept Recipes"

Transcription

1 StarCharter: A Tool for Mining Concept Recipes Steven She ECE750-T05: Static Analysis for Software Engineering November 28 st, 2008 Steven She StarCharter:A Tool for Mining Concept Recipes 1/22

2 Outline 1 Introduction 2 Concept Slicing 3 Data Mining 4 Walkthrough 5 Conclusions Steven She StarCharter:A Tool for Mining Concept Recipes 2/22

3 What is StarCharter? Makes a recipe describing framework usage using examples Steven She StarCharter:A Tool for Mining Concept Recipes 3/22

4 What is StarCharter? Makes a recipe describing framework usage using examples Steven She StarCharter:A Tool for Mining Concept Recipes 3/22

5 What is StarCharter? Makes a recipe describing framework usage using examples Steven She StarCharter:A Tool for Mining Concept Recipes 3/22

6 What sets StarCharter apart? Constructs a single recipe Recipe is a probabilistic model Used for tool support or framework modeling Address usage of white-box frameworks Steven She StarCharter:A Tool for Mining Concept Recipes 4/22

7 Overview Query Provide hints for finding concept events Concept Slicing Find related events Data Mining Find usage patterns among multiple examples Recipe Output a single probabilistic model describing usage Steven She StarCharter:A Tool for Mining Concept Recipes 5/22

8 Concept Slicing Reduce an example to a minimal set of statements that retains the specified behaviour Source code Steven She StarCharter:A Tool for Mining Concept Recipes 6/22

9 Concept Slicing Reduce an example to a minimal set of statements that retains the specified behaviour Source code Concept Slicer with Query Steven She StarCharter:A Tool for Mining Concept Recipes 6/22

10 Concept Slicing Reduce an example to a minimal set of statements that retains the specified behaviour Source code Concept Slicer with Query Relevant Events Steven She StarCharter:A Tool for Mining Concept Recipes 6/22

11 Forward Slice 1 public class HelloWorld extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 Image smiley; 5 6 public HelloWorld() { 7 smiley = getimage(getcodebase(), "images/smilegif"); 8 Container contentpane = getcontentpane(); 9 JLabel hwlabel = new JLabel(HELLO_WORLD); 10 contentpaneadd(hwlabel); 11 play(getcodebase(), "audio/woohoowav"); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 7/22

12 Forward Slice 1 public class HelloWorld extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 Image smiley; 5 6 public HelloWorld() { 7 smiley = getimage(getcodebase(), "images/smilegif"); 8 Container contentpane = getcontentpane(); 9 JLabel hwlabel = new JLabel(HELLO_WORLD); 10 contentpaneadd(hwlabel); 11 play(getcodebase(), "audio/woohoowav"); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 7/22

13 Backward Slice 1 public class HelloWorld extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 Image smiley; 5 6 public HelloWorld() { 7 smiley = getimage(getcodebase(), "images/smilegif"); 8 Container contentpane = getcontentpane(); 9 JLabel hwlabel = new JLabel(HELLO_WORLD); 10 contentpaneadd(hwlabel); 11 play(getcodebase(), "audio/woohoowav"); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 7/22

14 Backward Slice 1 public class HelloWorld extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 Image smiley; 5 6 public HelloWorld() { 7 smiley = getimage(getcodebase(), "images/smilegif"); 8 Container contentpane = getcontentpane(); 9 JLabel hwlabel = new JLabel(HELLO_WORLD); 10 contentpaneadd(hwlabel); 11 play(getcodebase(), "audio/woohoowav"); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 7/22

15 Unrelated Statements 1 public class HelloWorld extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 Image smiley; 5 6 public HelloWorld() { 7 smiley = getimage(getcodebase(), "images/smilegif"); 8 Container contentpane = getcontentpane(); 9 JLabel hwlabel = new JLabel(HELLO_WORLD); 10 contentpaneadd(hwlabel); 11 play(getcodebase(), "audio/woohoowav"); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 7/22

16 Framework Slicing Framework: javaxswing* 1 public class HelloWorldPresentation extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 5 public HelloWorldPresentation() { 6 Container contentpane = getcontentpane(); 7 JLabel hwlabel = new JLabel(HELLO_WORLD); 8 StringBuilder builder = new StringBuilder(HELLO_WORLD); 9 Formatter fmt = new Formatter(builder); 10 fmtformat("%s %s", HELLO_WORLD, HELLO_WORLD); 11 contentpaneadd(hwlabel); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 8/22

17 Framework Slicing Framework: javaxswing* 1 public class HelloWorldPresentation extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 5 public HelloWorldPresentation() { 6 Container contentpane = getcontentpane(); 7 JLabel hwlabel = new JLabel(HELLO_WORLD); 8 StringBuilder builder = new StringBuilder(HELLO_WORLD); 9 Formatter fmt = new Formatter(builder); 10 fmtformat("%s %s", HELLO_WORLD, HELLO_WORLD); 11 contentpaneadd(hwlabel); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 8/22

18 Framework Slicing Framework: javaxswing* 1 public class HelloWorldPresentation extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 5 public HelloWorldPresentation() { 6 Container contentpane = getcontentpane(); 7 JLabel hwlabel = new JLabel(HELLO_WORLD); 8 StringBuilder builder = new StringBuilder(HELLO_WORLD); 9 Formatter fmt = new Formatter(builder); 10 fmtformat("%s %s", HELLO_WORLD, HELLO_WORLD); 11 contentpaneadd(hwlabel); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 8/22

19 Framework Slicing Framework: javaxswing* 1 public class HelloWorldPresentation extends JApplet { 2 3 public static final String HELLO_WORLD = "Hello World!"; 4 5 public HelloWorldPresentation() { 6 Container contentpane = getcontentpane(); 7 JLabel hwlabel = new JLabel(HELLO_WORLD); 8 StringBuilder builder = new StringBuilder(HELLO_WORLD); 9 Formatter fmt = new Formatter(builder); 10 fmtformat("%s %s", HELLO_WORLD, HELLO_WORLD); 11 contentpaneadd(hwlabel); 12 } 13 } Steven She StarCharter:A Tool for Mining Concept Recipes 8/22

20 Sliced Events Example Location Event HelloWorld constructor add(component) HelloWorld constructor new JLabel(String) HelloWorld constructor getcontentpane() Store both the event and its location Steven She StarCharter:A Tool for Mining Concept Recipes 9/22

21 Concept Slicing Source code Concept Slicer with Query Relevant Events Steven She StarCharter:A Tool for Mining Concept Recipes 10/22

22 Creating the Recipe Events 1 Events 2 Events 3 Events 4 Sliced Events Steven She StarCharter:A Tool for Mining Concept Recipes 11/22

23 Creating the Recipe Events 1 Events 2 Events 3 Events 4 Sliced Events Data Miner Steven She StarCharter:A Tool for Mining Concept Recipes 11/22

24 Creating the Recipe Events 1 Events 2 Events 3 Events 4 Sliced Events Data Miner Recipe Steven She StarCharter:A Tool for Mining Concept Recipes 11/22

25 Feature Model Mining Mine for probabilistic expressions called Association Rules Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

26 Feature Model Mining Mine for probabilistic expressions called Association Rules Association Rule conf calls:getcontentpane() calls:add(component) 50% Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

27 Feature Model Mining Mine for probabilistic expressions called Association Rules Association Rule conf calls:getcontentpane() calls:add(component) 50% new:label calls:add(component) 100% Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

28 Feature Model Mining Mine for probabilistic expressions called Association Rules Association Rule conf calls:getcontentpane() calls:add(component) 50% new:label calls:add(component) 100% Hello World paint constructor 100% Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

29 Feature Model Mining Mine for probabilistic expressions called Association Rules Association Rule conf calls:getcontentpane() calls:add(component) 50% new:label calls:add(component) 100% Hello World paint constructor 100% Hello World constructor 67% Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

30 Feature Model Mining Mine for probabilistic expressions called Association Rules Association Rule conf calls:getcontentpane() calls:add(component) 50% new:label calls:add(component) 100% Hello World paint constructor 100% Hello World constructor 67% paint constructor 100% Steven She StarCharter:A Tool for Mining Concept Recipes 12/22

31 Mined Recipe Steven She StarCharter:A Tool for Mining Concept Recipes 13/22

32 Step 1: Input Query User stars a line of code in a framework application Extension: Possible to star several statements Steven She StarCharter:A Tool for Mining Concept Recipes 14/22

33 Step 1: Input Query User stars a line of code in a framework application Extension: Possible to star several statements Steven She StarCharter:A Tool for Mining Concept Recipes 14/22

34 Step 2: Find Related Usages Search the project for other instances of the starred code Scope currently restricted to a single class Use the Eclipse JDT SearchEngine Steven She StarCharter:A Tool for Mining Concept Recipes 15/22

35 Step 2: Find Related Usages Calls: References to calls of the same name class A { Formatter x = ; xformat(" ", x, y, z); } class B { Formatter y = ; yformat("hello %s!", x); } Steven She StarCharter:A Tool for Mining Concept Recipes 16/22

36 Step 2: Find Related Usages Variables: Assigned the same type or literal class A { JLabel label = new JLabel("Hello World!"); } class B { JLabel label = new JLabel("Test", LEFT); } Steven She StarCharter:A Tool for Mining Concept Recipes 17/22

37 Step 3: Slice Related Expression Input to Slicer: expression, class Construct a dependency graph for each class Nodes are expressions Edges are data dependence and control dependence Reachability determines slice example Steven She StarCharter:A Tool for Mining Concept Recipes 18/22

38 Step 3: Slice Related Expression Input to Slicer: expression, class Construct a dependency graph for each class Nodes are expressions Edges are data dependence and control dependence Reachability determines slice example Steven She StarCharter:A Tool for Mining Concept Recipes 18/22

39 Step 4: Data Mining One Slice is One Configuration Each expression in slice is a feature Expressions in the slice are unordered Also mine on structural properties Steven She StarCharter:A Tool for Mining Concept Recipes 19/22

40 Uses for the Tool 1 An enhanced search for references in Eclipse Ranks usages by comparing a related usage with the recipe Similar to PARSEWeb's clustering 2 The recipe is a model The recipe can be used for modelling FSMLs 3 Recipe as an expert system Using Herman's tool, it can act like FrUiT Steven She StarCharter:A Tool for Mining Concept Recipes 20/22

41 Uses for the Tool 1 An enhanced search for references in Eclipse Ranks usages by comparing a related usage with the recipe Similar to PARSEWeb's clustering 2 The recipe is a model The recipe can be used for modelling FSMLs 3 Recipe as an expert system Using Herman's tool, it can act like FrUiT Steven She StarCharter:A Tool for Mining Concept Recipes 20/22

42 Uses for the Tool 1 An enhanced search for references in Eclipse Ranks usages by comparing a related usage with the recipe Similar to PARSEWeb's clustering 2 The recipe is a model The recipe can be used for modelling FSMLs 3 Recipe as an expert system Using Herman's tool, it can act like FrUiT Steven She StarCharter:A Tool for Mining Concept Recipes 20/22

43 Conclusions Query Concept Slicing Data Mining Recipe Constructs a recipe from a set of examples Slicing finds related statements given a query Data mining merges sliced events from each example into a recipe Steven She StarCharter:A Tool for Mining Concept Recipes 21/22

44 Future Work Adding control dependence Fuzzy matching for literals Semantics for queries When is concept slicing useful? Steven She StarCharter:A Tool for Mining Concept Recipes 22/22