XSnippet: Mining For Sample Code
-
Upload
athena-gibson -
Category
Documents
-
view
43 -
download
5
description
Transcript of XSnippet: Mining For Sample Code
![Page 1: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/1.jpg)
XSnippet: Mining For Sample Code
Naiyana Tansalarak and Kajal Claypool
Presented by: Shan Li CISC864
![Page 2: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/2.jpg)
Topics
Overall of Research Purposes Contributions Approaches
Detail in Approaches
![Page 3: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/3.jpg)
Overall of Research
Purposes: To provide sample codes for new
developers to learn tech. quickly Approaches
Mining sample codes from existing software systems
![Page 4: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/4.jpg)
Overall of Research cont. Steps in Approaches
Range of Queries generalized / specialized? Ranking Heuristics for context-sensitive /
context-independence Such as: constructor function / constructor
function of DOM Mining Algorithms
BFSMINE Alg. , restricts: inside a scope of a method
Extensions to BFSMINE Alg.
![Page 5: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/5.jpg)
Approaches: the Snippet Mining Processes
Figure1: A high-level view of the snippet Mining Process
![Page 6: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/6.jpg)
Approaches cont. The goal of the snippet mining is to mine from a
given code sample repository all code snippets that satisfy a given user query Q,
SelectionAgent pre-selects a set of code model instances cmi on B+ tree index defined on all types declared or referred to in the code sample repository.
The MiningAgent invokes the BFSMINE algorithm for every code model instance Ccmi
![Page 7: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/7.jpg)
Approaches cont. BFSMINE algorithm traverses a code model
instance and produces as output a set of paths P that represent the final code snippets returned to the user.
On completion of the BFSMINE phase, the MiningAgent passes the collection of the paths P, to the PruningAgent.
![Page 8: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/8.jpg)
Approaches cont. Queries
The query retun all snippets s,
containing codes that instantiate a type tq:
(1) all codes that instantiate tq:
(2) instantiation of tq is dependent of the code context, i.e. via a static method
The following example
![Page 9: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/9.jpg)
Approaches cont.
![Page 10: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/10.jpg)
Approaches cont. Queries
A type-based instantiation query tq is instantiated from any type from the
context CT(m) T (s) the lexically visible types in the
code snippet s and CT (m) denotes the type context of the method
CT (m) : all set of inherited types, visible types in a scope of method, all types for local fields
![Page 11: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/11.jpg)
Approaches cont.
![Page 12: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/12.jpg)
Approaches cont. Queries
Parent-based in instantiation query s denotes a snippet, CP (s) the parent
context of the snippet, CP (m) the parent context of the method m.
CP (m): The parent context of a method m, denoted as CP (m), is a set containing the superclass extended by its containing source class C, as well as all interfaces implemented by its containing source class C.
![Page 13: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/13.jpg)
Approaches cont.
![Page 14: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/14.jpg)
Approaches cont. Source Code Model
A graphic representation of the structure of source codes. Nodes: a type node, an object node, a method node
Edges: inheritance, implement, composite, method, assignment or parameter edge.
![Page 15: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/15.jpg)
Approaches cont. BFSMINE Algorithm
Given a user query , The goal of the BFSMINE algorithm is to determine for all such instances nq, types and eventually code segments that instantiate the node nq and hence the query type tq. Domain(nq) = {tq}
![Page 16: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/16.jpg)
Approaches cont.
![Page 17: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/17.jpg)
Approaches cont.
Extension-BFSMIN
![Page 18: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/18.jpg)
Approaches cont.
Extension-BFSMIN
![Page 19: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/19.jpg)
Approaches cont.
![Page 20: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/20.jpg)
Personal Comments Strengths
User defined queries Results from a context-independent retrieval
to various degrees of context-sensitive retrieval
BFSMIN Algorithm based on a graph that represents a source code model allows mining across method boundaries
Ranking heuristic (length, frequency, context ) for providing best-fit code snippets
Multiple sample codes with the same query context-independent retrieval (length / frequency ) context-sensitive retrieval (context)
![Page 21: XSnippet: Mining For Sample Code](https://reader036.fdocuments.in/reader036/viewer/2022062314/56813518550346895d9c6e45/html5/thumbnails/21.jpg)
Personal Comments Potential weakness
Results Is it possible to provide semantic ranking ? Why? Probably, the return code snippets do not
have logic among them, just only a chunk of codes Validation approaches
To prove that snippet codes is helpful for developers, authors use group test. Two groups with the same condition except that one uses snippet codes, other do not.
Limited ?