milestone: exoa: example-oriented api

22
Milestone: eXoa: Example-oriented API Sanghoon Lee POSTECH with Jinhan Kim, Seung-won Hwang, Sunghun Kim July 10, 2009

Upload: others

Post on 22-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Milestone: eXoa: Example-oriented API

Milestone:eXoa: Example-oriented APIeXoa: Example-oriented API

Sanghoon LeePOSTECH

withJinhan Kim, Seung-won Hwang, Sunghun Kim

July 10, 2009

Page 2: Milestone: eXoa: Example-oriented API

Contents

• Introduction• eXoa– Overview– Using Source code repositories– Summarization– Summarization– Diversification– Ranking– Embedding

• Evaluation• Case Study• Improvements

Page 3: Milestone: eXoa: Example-oriented API

MSDN

Page 4: Milestone: eXoa: Example-oriented API

No examples !!!

Javadoc

Page 5: Milestone: eXoa: Example-oriented API

Javadoc + Examples =Example Oriented API documentation

Examples

Javadoc

Page 6: Milestone: eXoa: Example-oriented API

Good Examples

• Simplicity

• Various Usages

Page 7: Milestone: eXoa: Example-oriented API

Overview of eXoa

CandidatesWeb Summarized codes

Summarization

Diversification

K-means

Query

Clusters

Ranking

Javadoc

exoa

3

3

32 …

2 …

2 …

1

1

1

Embedding

f

Page 8: Milestone: eXoa: Example-oriented API

Using Source code repositoriesWeb

Javadoc

Query

Candidates

ArrayList classboolean add(E e)void add(int index, E element)boolean addAll(Collection c)boolean addAll(int index, Collection c)void clear()…

Javadoc

Page 9: Milestone: eXoa: Example-oriented API

Summarization

Java2XML

CandidatesSummarized

codes

Summarization Method-based sliced code

1 : Method

1 : Formal-arguments1 : Type

1 : Formal-argument

1 : Type

Block

2 : Local-variable 5 : Send……

2 : Arguments

2 : Type 2 : New

2 : Type

2 : Literal-char

5 : Target

5 : Var-ref

5 : Arguments

5 : Send 5 : Literal-number

5 : Target 5 : Arguments

Java2XML

AbstractSyntax Tree (AST)

Page 10: Milestone: eXoa: Example-oriented API

Summarization

1 : Method

1 : Formal-arguments1 : Type

1 : Formal-argument

1 : Type

Block

2 : Local-variable 5 : Send……

2 : Arguments

2 : Type 2 : New

2 : Type

5 : Target

5 : Var-ref

5 : Arguments

5 : Send 5 : Literal-number

CandidatesSummarized

codes

Summarization

AST

Line Class API name Arguments

4 a : Character : 2 hashCode

5 b : Character : 3 hashCode

4 harness : TestHarness : 1 check int, int

5 harness : TestHarness : 1 check int, int

… … … …

2 : Arguments2 : Type

2 : Literal-char

5 : Var-ref 5 : Send 5 : Literal-number

5 : Target 5 : Arguments

IntraAnalysis

Table(IAT)

Page 11: Milestone: eXoa: Example-oriented API

Diversification

• Similarity comparison– String-based matching– Tree-based matching– Characteristic vector-based matching

(Deckard, ICSE07)

Summarized codes

Diversification

K-means

1 : Method

1 : Formal-arguments1 : Type

1 : Formal-argument

1 : Type

Block

2 : Local-variable 5 : Send……

2 : Arguments

2 : Type 2 : New

2 : Type

2 : Literal-char

5 : Target

5 : Var-ref

5 : Arguments

5 : Send 5 : Literal-number

5 : Target 5 : Arguments

(1, 0, 0, 1, 3, 0, 0, … , 2, 1, 0, 1)

Page 12: Milestone: eXoa: Example-oriented API

Diversification

Summarized codes

Diversification

K-means

K=2 K=3

K=5K=4

Page 13: Milestone: eXoa: Example-oriented API

Ranking• The most representative example in

a cluster• Measures

– Distance from centroid– Conciseness– Correctness+ User Feedback

K=3

3

3

32 …

2 …

2 …

1

1

1

f

K=3

Page 14: Milestone: eXoa: Example-oriented API

EmbeddingJavadoc

exoa

3

3

32…

2…

2…

1

1

1

Popularity

Codeexample

UserFeedback

http://ids.postech.ac.kr:8080/java6/api/

Page 15: Milestone: eXoa: Example-oriented API

Evaluation

• Comparison with Koders– Accuracy

– Diversification• Koders : 30.8% are duplicated (among 22%)• eXoa : only 8.7% are duplicated (among 92%)

Page 16: Milestone: eXoa: Example-oriented API

Case Study

• Productivity • Code quality

• Cognitive load

Page 17: Milestone: eXoa: Example-oriented API

Developer Feedback

Joel Spolsky: “I think this is a fantastic idea. Just yesterday, I was facing this exact problem… the API documentation wasn’t good enough, and I would have killed for a couple of examples. It sounds like a very smart idea…”

Developer 2: "Automatic example finding sounds really good. This would help developers significantly. In fact, I was struggled many times to understand APIs without examples.“

Developer 3: "API documents that have code example is really helpful... Using these code examples, I can reduce develop time significantly. However, JavaDocs provides very few code examples, so I need to find additional code examples. I like MSDN because most functions and methods contain code examples. For this reason, automatically finding and adding code examples seems a wonderful idea..."

Page 18: Milestone: eXoa: Example-oriented API

Improvements - 1

CandidatesWeb Summarized codes

Summarization

Diversification

K-means

Query

Crawler

Clusters

Ranking

Javadoc

exoa

3

3

32 …

2 …

2 …

1

1

1

Embedding

f

Repository

Page 19: Milestone: eXoa: Example-oriented API

Improvements - 2http://koders.com/default.aspx?s=ArrayList+add&btn=&la=Java

Web services

Repository

Open sourceRepositories

Web services

Page 20: Milestone: eXoa: Example-oriented API

Improvements - 3

• Simplify examples on a method call

Page 21: Milestone: eXoa: Example-oriented API

Improvements - 4

Examplesource codes Usage

Representativeexamples

Clustering Ranking

To be continued in ‘Lightning talk’…

Page 22: Milestone: eXoa: Example-oriented API

Q & AQ & A

Thank you for listening …