Using Structural Context to Recommend Source Code Examples - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Using Structural Context to Recommend Source Code Examples

Description:

Calls With Inheritance Heuristic ... We claim that our approach requires less effort for developers to use. Example Repository ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 21
Provided by: reidh7
Category:

less

Transcript and Presenter's Notes

Title: Using Structural Context to Recommend Source Code Examples


1
Using Structural Context to Recommend Source
Code Examples
  • Reid Holmes and Gail C. Murphy

2
The Problem A Concrete Example
  • Frameworks can improve developer productivity.
    But developers can become stuck trying to use the
    APIs
  • Imagine trying to use the Eclipse APIs to place
    text in the status line of the Eclipse IDE
  • Eclipse has 38,000 public methods

3
The Problem A Concrete Example
Search the documentation status line eclipse
4
The Problem A Concrete Example
  • An expert might reveal
  • How can we deliver this kind of example to a
    developer?

5
Previous Approaches
  • Past approaches have tried to deliver examples
  • Reuse View Matcher Rosson Carroll 91
  • Provide constructed examples to developers
  • Framework developer must explicitly create
    examples
  • CodeFinder Henninger 91
  • Help developers construct effective queries
  • Developer needs to construct query manually
  • CodeBroker Ye Fischer 01,02
  • Locate similar code using comments and method
    signatures
  • Intent is to locate similar code, not usage

6
Our Approach An Overview
Development Environment
7
Strathcona User Perspective
Write Code Fragment
Extract Structural Context
Browse Examples
Integrate Relevant Code
User Actions
Strathcona Actions
8
Strathcona Extract Structural Context
ViewPart
9
Strathcona Example Navigation
  • Visual representation
  • Highlights key relationships between example and
    query
  • Multiple examples can be quickly viewed

10
Strathcona Viewing Example Source
  • Code view
  • Example shows how to get a status line manager
  • Example is not a perfect match, but good enough
    to help

11
Strathcona Server Side
  • Repository consists of existing projects
  • Structural context is automatically extracted
  • Examples are not pre-computed
  • Relevant source is located by heuristics
  • Example is built from relevant code
  • Eclipse example repository consists of source for
    release 3.0
  • 17,456 classes
  • 124,359 methods
  • 1,066,838 calls
  • 15,187 inheritance links

Write Code Fragment
Existing Projects
Project Repository
Strathcona Server
Browse Examples
Integrate Relevant Code
12
Strathcona Heuristics
  • Six heuristics locate structurally relevant
    examples
  • Inheritance
  • Calls
  • Calls with inheritance
  • Uses
  • Uses with inheritance
  • Calls best fit
  • Inspired by how a developer might manually search
  • Each heuristic generates a set of examples
  • Results from each are combined
  • Top ten examples are returned

13
Heuristics Example
Structural Context
14
Calls Heuristic
  • Locate examples that make similar method calls

Matched Example
Structural Context
15
Calls With Inheritance Heuristic
  • Locate examples that make similar method calls
    and have similar parents

Matched Example
Structural Context
16
Calls Best Fit Heuristic
Locate examples that dont make too many
extraneous method calls
Potential Example
Structural Context
17
Evaluation
  • We claim that our approach requires less effort
    for developers to use
  • Example Repository
  • Automatically populated
  • Forming queries
  • Automatically created from context of editor
  • Query performance
  • Queries take from 3 to 10 seconds
  • Question addressed
  • Can developers recognize and use examples?

18
Case Study
  • Evaluating the effectiveness of delivered
    examples
  • Two subjects, both new to the Eclipse framework
  • Each given the same four development tasks
  • All tasks encountered during Strathcona
    development
  • Each were provided with code fragment identified
    from the documentation
  • Subjects were asked to use Strathcona to help
    them complete the tasks within 3 hours

19
Case Study
  • Subject one completed all 4 tasks
  • Subject two completed 3 of the 4 tasks
  • Solutions were of high quality
  • Included error cases they hadnt originally
    considered
  • Subjects recognized examples that were not useful
  • Subjects created new query fragments unexpected
    by us

20
Discussion
  • Can developers create appropriate context to
    query on?
  • Informal evaluation shows that they can create
    fragments to form queries with
  • Are these really examples?
  • Hand-crafted examples help developers understand
    how and why to use an API
  • Our examples provide help in the usage of an API

21
Conclusion
  • Structural context can provide relevant examples
    with less effort than previous approaches
  • Example repositories can be easily populated
  • Automatically form query based on the code a
    developer is writing
  • Developers can use examples to complete tasks

http//cs.ucalgary.ca/rtholmes/strathcona
Write a Comment
User Comments (0)
About PowerShow.com