SlideShare uma empresa Scribd logo
1 de 75
Baixar para ler offline
Recommending Proper API Code Examples
     for Documentation Purpose
       Lee Wei Mar, Ye-Chi Wu, and Hewijin Christine Jiau

              DBSE Lab @ Inst. CCE & Dept. EE
        National Cheng Kung University (NCKU), Taiwan
Outline

• Introduction

• Code Search Engines for Code Example Collection

• The Proposed Methodology - PropER-Doc
    – Execution Process

    – Recommendation Assistants

• Evaluation

• Conclusion
Introduction


• Nowadays, object-oriented frameworks & libraries offer powerful APIs

   that facilitate programmers in accomplishing their works
Introduction


• Nowadays, object-oriented frameworks & libraries offer powerful APIs

   that facilitate programmers in accomplishing their works




               Power ↑    API Complexity ↑   Learning Barrier ↑
Introduction


• Nowadays, object-oriented frameworks & libraries offer powerful APIs

   that facilitate programmers in accomplishing their works

                             Hamper


               Power ↑    API Complexity ↑   Learning Barrier ↑
Introduction


• Nowadays, object-oriented frameworks & libraries offer powerful APIs

   that facilitate programmers in accomplishing their works

                             Hamper


               Power ↑    API Complexity ↑   Learning Barrier ↑




To ensure the facilitation, offering effective API learning resources
is essential for API providers
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning
                        Eclipse SWT




      public class Snippet26 {
       public static void main (String [] args) {
         Display display = new Display ();
         Shell shell = new Shell (display);
         Combo combo = new Combo (shell, SWT.READ_ONLY);
         combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"});
         Rectangle clientArea = shell.getClientArea ();
         combo.setBounds (clientArea.x, clientArea.y, 200, 200);
         shell.pack ();
         shell.open ();
         ….
      }



          Independent CE repository
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning
                        Eclipse SWT                                                    Eclipse JDT




      public class Snippet26 {
       public static void main (String [] args) {
         Display display = new Display ();
         Shell shell = new Shell (display);
         Combo combo = new Combo (shell, SWT.READ_ONLY);
         combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"});
         Rectangle clientArea = shell.getClientArea ();
         combo.setBounds (clientArea.x, clientArea.y, 200, 200);
         shell.pack ();
         shell.open ();
         ….
      }



          Independent CE repository                                            Embedding CE in API reference
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning

          Guide programmers to properly use API by demonstration
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning

           Guide programmers to properly use API by demonstration


• However, many APIs fail to offer sufficient CEs
Introduction (cont.)

• Code examples (CEs) are effective resources for API learning

           Guide programmers to properly use API by demonstration


• However, many APIs fail to offer sufficient CEs


       API providers must invest large human effort for CE
       construction from scratch
CSEs for Code Example Collection


• Code Search Engines (CSEs) are potentially useful in CE collection

                  query


   API provider
                                                     source files potentially
                                                      use the API element
CSEs for Code Example Collection


• Code Search Engines (CSEs) are potentially useful in CE collection

                    query


     API provider
                                                       source files potentially
                                                        use the API element



The signature of a specific API element
is given as the query keyword
CSEs for Code Example Collection


• Code Search Engines (CSEs) are potentially useful in CE collection

                    query


     API provider
                                                              source files potentially
                                                               use the API element



The signature of a specific API element
is given as the query keyword             • These files contain “client code” that
                                            demonstrates the use of the API element

                                          • The client code can be treated as
                                            “candidates” of CEs for documentation
CSEs for Code Example Collection - Challenges


• Code Search Engines (CSEs) are potentially useful in CE collection

                  query


   API provider
                                                     source files potentially
                                                      use the API element


  API providers must manually
CSEs for Code Example Collection - Challenges


• Code Search Engines (CSEs) are potentially useful in CE collection

                  query


   API provider
                                                                        source files potentially
                                                                         use the API element


  API providers must manually
     1. Locate API usage code scattered in source files as candidates

     2. Reorganize candidates according to different usages

     3. Check appropriateness of candidates for documentation
CSEs for Code Example Collection - Challenges


• Code Search Engines (CSEs) are potentially useful in CE collection

                  query


   API provider
                                                                        source files potentially
                                                                         use the API element


  API providers must manually
     1. Locate API usage code scattered in source files as candidates

     2. Reorganize candidates according to different usages

     3. Check appropriateness of candidates for documentation

     These manual efforts must be reduced to make such practice applicable
The Proposed Methodology – PropER-Doc


• Proper code Example candidates Recommendation for Documentation
    – Use API element links to guide the recommendation from CSE results
The Proposed Methodology – PropER-Doc


• Proper code Example candidates Recommendation for Documentation
    – Use API element links to guide the recommendation from CSE results


        Links between API elements to indicate the joint use relationship

             •    Structural Links from structural dependencies in API implementation
             •    Conceptual Links from cross references in API documentation
The Proposed Methodology – PropER-Doc


• Proper code Example candidates Recommendation for Documentation
    – Use API element links to guide the recommendation from CSE results


        Links between API elements to indicate the joint use relationship

             •    Structural Links from structural dependencies in API implementation
             •    Conceptual Links from cross references in API documentation


    – Offer recommendation assistants for candidate inspection & selection
PropER-Doc Execution Process


                                                       perform
               targetType query     Candidate         code search
                                    Collection
API Provider
                                             candidates

                                                      check API call
                                    Candidate          significance
 candidate suggestion               Annotation

                                             annotated
                                             candidates


                                     Candidate
                                  Recommendation
PropER-Doc Execution Process


                                                perform
               targetType query   Candidate    code search
                                  Collection
API Provider
PropER-Doc Execution Process


                                                  perform
                 targetType query   Candidate    code search
                                    Collection
  API Provider


The API provider gives a name
of the API type that needs CEs
PropER-Doc Execution Process


                                                  perform
                 targetType query   Candidate    code search
                                    Collection
  API Provider


The API provider gives a name
of the API type that needs CEs                   The query is delegated to CSEs
PropER-Doc Execution Process


                                                           perform
                 targetType query    Candidate            code search
                                     Collection
  API Provider
                                                 candidates
The API provider gives a name
of the API type that needs CEs                                The query is delegated to CSEs




         •   PropER-Doc collects candidates from CSE results
         •   Candidate: a method implementation that refers targetType
             usage
PropER-Doc Execution Process


                                                     perform
               targetType query   Candidate         code search
                                  Collection
API Provider
                                           candidates

                                                    check API call
                                  Candidate          significance
                                  Annotation
PropER-Doc Execution Process


                                                                     perform
                               targetType query   Candidate         code search
                                                  Collection
                API Provider
                                                           candidates

                                                                    check API call
For each API call, annotate it with a
                                                  Candidate          significance
significance degree                               Annotation
           6                   0
   (relevant)                  (irrelevant)
PropER-Doc Execution Process


                                                                     perform
                               targetType query   Candidate         code search
                                                  Collection
                API Provider
                                                           candidates

                                                                    check API call
For each API call, annotate it with a
                                                  Candidate          significance
significance degree                               Annotation
           6                   0
   (relevant)                  (irrelevant)
                                                           annotated
                                                           candidates
PropER-Doc Execution Process


                                                           perform
                   targetType query     Candidate         code search
                                        Collection
    API Provider
                                                 candidates

                                                          check API call
candidate suggestion
                                        Candidate          significance
                                        Annotation

                                                 annotated
                                                 candidates


                                         Candidate
                                      Recommendation
PropER-Doc Execution Process


                                                              perform
                      targetType query     Candidate         code search
                                           Collection
       API Provider
                                                    candidates

                                                             check API call
candidate suggestion
                                           Candidate          significance
                                           Annotation
   recommendation
with

assistants                                          annotated
                                                    candidates


                                            Candidate
                                         Recommendation
Candidate Recommendation


Four Recommendation Assistants are offered to guide the recommendation
Candidate Recommendation


  Four Recommendation Assistants are offered to guide the recommendation


    [All candidates]




    Grouping for
distinguishing API usages
Candidate Recommendation


  Four Recommendation Assistants are offered to guide the recommendation


    [All candidates]        [A selected group]




    Grouping for            Diagramming API
distinguishing API usages     types interaction
Candidate Recommendation


  Four Recommendation Assistants are offered to guide the recommendation


    [All candidates]        [A selected group]    [Candidates in a group]




    Grouping for            Diagramming API        Ranking based on
distinguishing API usages     types interaction   appropriateness metrics
Candidate Recommendation


  Four Recommendation Assistants are offered to guide the recommendation


    [All candidates]        [A selected group]    [Candidates in a group]   [A selected candidate]




    Grouping for            Diagramming API        Ranking based on           Presenting      the
distinguishing API usages     types interaction   appropriateness metrics   candidate for inspection
Recommendation - Clustering
       Grouping               Diagramming             Ranking   Presenting


[All candidates] – Distinguish different API usages
Recommendation - Clustering
       Grouping               Diagramming             Ranking               Presenting


[All candidates] – Distinguish different API usages


  Rationale: In different usages, targetType tends to interact with different   API types
Recommendation - Clustering
       Grouping               Diagramming             Ranking               Presenting


[All candidates] – Distinguish different API usages


  Rationale: In different usages, targetType tends to interact with different   API types

 •   PropER-Doc extracts iTypes of each
     candidate
      – iTypes: the set of API types where
        targetType directly interacts with


 •   Candidates with the same iTypes tend
     to demonstrate the same usage and are
     grouped together
Recommendation - Clustering
       Grouping               Diagramming             Ranking               Presenting


[All candidates] – Distinguish different API usages


  Rationale: In different usages, targetType tends to interact with different   API types

 •   PropER-Doc extracts iTypes of each
     candidate
      – iTypes: the set of API types where
        targetType directly interacts with


 •   Candidates with the same iTypes tend
     to demonstrate the same usage and are
     grouped together
Recommendation - Clustering
       Grouping              Diagramming   Ranking   Presenting


[One group is selected for inspection]
Recommendation - Clustering
       Grouping              Diagramming            Ranking             Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage
Recommendation - Clustering
       Grouping              Diagramming             Ranking            Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
Recommendation - Clustering
       Grouping              Diagramming             Ranking            Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
                                                      – Box: API Type
Recommendation - Clustering
       Grouping              Diagramming             Ranking                Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
                                                      – Box: API Type
                                                      – Edge / Label: interaction / API calls
Recommendation - Clustering
       Grouping              Diagramming             Ranking                Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
                                                      – Box: API Type
                                                      – Edge / Label: interaction / API calls
                                                      – API call popularity
Recommendation - Clustering
       Grouping              Diagramming             Ranking                Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
                                                      – Box: API Type
                                                      – Edge / Label: interaction / API calls
                                                      – API call popularity
Recommendation - Clustering
       Grouping              Diagramming             Ranking                Presenting


[One group is selected for inspection]


      Use visual   notation to summarize API type interaction of a specific usage

                                                 •   Visual Grammar
                                                      – Box: API Type
                                                      – Edge / Label: interaction / API calls
                                                      – API call popularity



                                                 • Selection of interested API calls for
                                                   filtering candidates
Recommendation - Clustering
       Grouping             Diagramming                Ranking         Presenting


[A set of similar candidates demonstrating the same usage is chosen]
Recommendation - Clustering
       Grouping             Diagramming                Ranking         Presenting


[A set of similar candidates demonstrating the same usage is chosen]



  Which one is more appropriate for documentation and should be inspected first?
Recommendation - Clustering
       Grouping             Diagramming                Ranking           Presenting


[A set of similar candidates demonstrating the same usage is chosen]

            Define three appropriateness       metrics to rank the candidates
Recommendation - Clustering
        Grouping                    Diagramming                      Ranking                  Presenting


[A set of similar candidates demonstrating the same usage is chosen]

               Define three appropriateness                metrics to rank the candidates

       Significance                                Density                          Cohesiveness
 Importance of referred API calls        Portion of relevant API calls         Degree of relevant call aggregation



                     >                                  >                                        >
        more                                  more
    representative                        comprehensible                         easier extraction




  Candidate                    Statements with significance degree
                                     6                 0
Recommendation - Clustering
       Grouping              Diagramming         Ranking            Presenting


[A set of candidates is chosen]


         Rank function: f(c) = Significance(c) + Density(c) + Cohesiveness(c)
Recommendation - Clustering
       Grouping              Diagramming                Ranking   Presenting


[A candidate is selected for inspection & CE construction]
Recommendation - Clustering
       Grouping              Diagramming                Ranking        Presenting


[A candidate is selected for inspection & CE construction]

      Highlight relevant code place to facilitate code inspection & extraction
Recommendation - Clustering
       Grouping              Diagramming                Ranking        Presenting


[A candidate is selected for inspection & CE construction]

      Highlight relevant code place to facilitate code inspection & extraction
Recommendation - Clustering
       Grouping               Diagramming               Ranking        Presenting


[A candidate is selected for inspection & CE construction]

      Highlight relevant code place to facilitate code inspection & extraction




      Important code blocks are highlighted
Recommendation - Clustering
       Grouping               Diagramming               Ranking        Presenting


[A candidate is selected for inspection & CE construction]

      Highlight relevant code place to facilitate code inspection & extraction




                                                                  Key API elements are
                                                                  marked as bold



      Important code blocks are highlighted
Evaluation

• Objective: check PropER-Doc effectiveness on
    A. Distinguishing different API usages among candidates
    B. Suggesting proper candidates for CEs construction


• Procedure
    1.   For an API type, manually identify its typical usages (U1) that need CEs
    2.   Use PropER-Doc to collect candidates and distinguish the API type usages (U2)
    3.   Map between U1 and U2 (objective A)
    4.   For each usage in U1, use PropER-Doc to select the top-ranked candidate
    5.   Evaluate the effort for constructing CE from top-ranked candidate (objective B)


• Subject: ASTParser class (A complex API type in Eclipse JDT framework)
Evaluation Result – Mapping Result

U1                                     U2 (GID)
Get AST from ICompilationUnit          1
Get AST from a string of class body    2
Get AST from a string of statements    3
Get AST from a string of expression    4
Get AST from ITypRoot                  5
Get IJavaElement binding info.         6

Get AST from source code               7
Get ASTs from ICompilationUnits        8
Get AST from IClassFile                9
Evaluation Result – Mapping Result

U1                                     U2 (GID)   •   Mostly 1   : 1 mapping
Get AST from ICompilationUnit          1
Get AST from a string of class body    2
Get AST from a string of statements    3
Get AST from a string of expression    4
Get AST from ITypRoot                  5
Get IJavaElement binding info.         6

Get AST from source code               7
Get ASTs from ICompilationUnits        8
Get AST from IClassFile                9
Evaluation Result – Mapping Result

U1                                     U2 (GID)   •   Mostly 1   : 1 mapping
Get AST from ICompilationUnit          1               –   Confirm the effectiveness of the
Get AST from a string of class body    2
                                                           grouping assistant in PropER-Doc

Get AST from a string of statements    3
Get AST from a string of expression    4
Get AST from ITypRoot                  5
Get IJavaElement binding info.         6

Get AST from source code               7
Get ASTs from ICompilationUnits        8
Get AST from IClassFile                9
Evaluation Result – Mapping Result

U1                                     U2 (GID)   •   Mostly 1    : 1 mapping
Get AST from ICompilationUnit          1               –   Confirm the effectiveness of the
Get AST from a string of class body    2
                                                           grouping assistant in PropER-Doc

Get AST from a string of statements    3
Get AST from a string of expression    4
                                                  •   For the 3   : 1 mapping, the
                                                      diagramming assistant is useful in
Get AST from ITypRoot                  5              distinguishing different usages
Get IJavaElement binding info.         6

Get AST from source code               7
Get ASTs from ICompilationUnits        8
Get AST from IClassFile                9
Evaluation Result – Mapping Result

U1                                     U2 (GID)   •   Mostly 1    : 1 mapping
Get AST from ICompilationUnit          1               –   Confirm the effectiveness of the
Get AST from a string of class body    2
                                                           grouping assistant in PropER-Doc

Get AST from a string of statements    3
Get AST from a string of expression    4
                                                  •   For the 3   : 1 mapping, the
                                                      diagramming assistant is useful in
Get AST from ITypRoot                  5              distinguishing different usages
Get IJavaElement binding info.         6

Get AST from source code               7
Get ASTs from ICompilationUnits        8
Get AST from IClassFile                9



     The Grouping and Diagramming assistants are useful
            in distinguishing different API usages
Evaluation Result – Constructing Effort

U1                                    ∆Stmt (+/-) Coh.
Get AST from ICompilationUnit              0/0            1.00

Get AST from a string of class body        0/0            1.00

Get AST from a string of statements        0/0            1.00

Get AST from a string of expression        4/0            1.00

Get AST from ITypRoot                      0/1            1.00

Get IJavaElement binding info.             3/0            1.00

Get AST from source code                   0/0            1.00

Get ASTs from ICompilationUnits           16 / 0          0.63

Get AST from IClassFile                    0/0            1.00

∆Stmt (+/-): #(extra statements) / #(missed statements)
Coh.:        Cohesiveness (between 0 and 1)
Evaluation Result – Constructing Effort

U1                                    ∆Stmt (+/-) Coh.           • 5 of 9 top candidates can be
Get AST from ICompilationUnit              0/0            1.00      directly used as CEs

Get AST from a string of class body        0/0            1.00

Get AST from a string of statements        0/0            1.00

Get AST from a string of expression        4/0            1.00

Get AST from ITypRoot                      0/1            1.00

Get IJavaElement binding info.             3/0            1.00

Get AST from source code                   0/0            1.00

Get ASTs from ICompilationUnits           16 / 0          0.63

Get AST from IClassFile                    0/0            1.00

∆Stmt (+/-): #(extra statements) / #(missed statements)
Coh.:        Cohesiveness (between 0 and 1)
Evaluation Result – Constructing Effort

U1                                    ∆Stmt (+/-) Coh.           • 5 of 9 top candidates can be
Get AST from ICompilationUnit              0/0            1.00      directly used as CEs

Get AST from a string of class body        0/0            1.00

Get AST from a string of statements        0/0            1.00   • Only 1 top candidate misses 1
                                                                    statement for CE construction
Get AST from a string of expression        4/0            1.00
                                                                    – Top candidates contains almost all
Get AST from ITypRoot                      0/1            1.00        required API calls for CE construction

Get IJavaElement binding info.             3/0            1.00

Get AST from source code                   0/0            1.00

Get ASTs from ICompilationUnits           16 / 0          0.63

Get AST from IClassFile                    0/0            1.00

∆Stmt (+/-): #(extra statements) / #(missed statements)
Coh.:        Cohesiveness (between 0 and 1)
Evaluation Result – Constructing Effort

U1                                    ∆Stmt (+/-) Coh.           • 5 of 9 top candidates can be
Get AST from ICompilationUnit              0/0            1.00      directly used as CEs

Get AST from a string of class body        0/0            1.00

Get AST from a string of statements        0/0            1.00   • Only 1 top candidate misses 1
                                                                    statement for CE construction
Get AST from a string of expression        4/0            1.00
                                                                    – Top candidates contains almost all
Get AST from ITypRoot                      0/1            1.00        required API calls for CE construction

Get IJavaElement binding info.             3/0            1.00

Get AST from source code                   0/0            1.00   • High cohesiveness in all top
                                                                    candidates
Get ASTs from ICompilationUnits           16 / 0          0.63
                                                                    – Effort for relevant code extraction
Get AST from IClassFile                    0/0            1.00        from top candidates is quite low

∆Stmt (+/-): #(extra statements) / #(missed statements)
Coh.:        Cohesiveness (between 0 and 1)
Evaluation Result – Constructing Effort

U1                                    ∆Stmt (+/-) Coh.   • 5 of 9 top candidates can be
Get AST from ICompilationUnit            0/0      1.00      directly used as CEs

Get AST from a string of class body      0/0      1.00

Get AST from a string of statements      0/0      1.00   • Only 1 top candidate misses 1
                                                            statement for CE construction
Get AST from a string of expression      4/0      1.00
                                                            – Top candidates contains almost all
Get AST from ITypRoot                    0/1      1.00        required API calls for CE construction

Get IJavaElement binding info.           3/0      1.00

Get AST from source code                 0/0      1.00   • High cohesiveness in all top
                                                            candidates
Get ASTs from ICompilationUnits          16 / 0   0.63
                                                            – Effort for relevant code extraction
Get AST from IClassFile                  0/0      1.00        from top candidates is quite low



        PoperER-Doc suggests high quality candidates
                    for CEs construction
Conclusion

• PropER-Doc is proposed to assist API providers in constructing proper API
  code examples using code search engines

    1. Candidate grouping algorithm



    2. API-type interaction diagram


    3. Metrics-based ranking mechanism
Conclusion

• PropER-Doc is proposed to assist API providers in constructing proper API
  code examples using code search engines

    1. Candidate grouping algorithm            Distinguish different API usages


    2. API-type interaction diagram


    3. Metrics-based ranking mechanism
Conclusion

• PropER-Doc is proposed to assist API providers in constructing proper API
  code examples using code search engines

    1. Candidate grouping algorithm              Distinguish different API usages


    2. API-type interaction diagram      Inspect specific usage & filter candidates



    3. Metrics-based ranking mechanism
Conclusion

• PropER-Doc is proposed to assist API providers in constructing proper API
  code examples using code search engines

    1. Candidate grouping algorithm              Distinguish different API usages


    2. API-type interaction diagram      Inspect specific usage & filter candidates



    3. Metrics-based ranking mechanism           Select high quality candidates
Conclusion

• PropER-Doc is proposed to assist API providers in constructing proper API
  code examples using code search engines

    1. Candidate grouping algorithm              Distinguish different API usages


    2. API-type interaction diagram      Inspect specific usage & filter candidates



    3. Metrics-based ranking mechanism           Select high quality candidates


• Evaluation on Eclipse JDT framework has been conducted to confirm the
  effectiveness of PropER-Doc
Thank You
               Lee Wei Mar (馬立偉)
            lwmar@nature.ee.ncku.edu.tw

      Database and Software Engineering Laboratory,
Institute of Computer and Communication Engineering &
           Department of Electrical Engineering,
     National Cheng Kung University, Tainan, Taiwan

Mais conteúdo relacionado

Destaque

MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell InspectionMAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
立偉 馬
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution
立偉 馬
 
KCB101 storyboard MK AN
KCB101 storyboard MK ANKCB101 storyboard MK AN
KCB101 storyboard MK AN
ash2007080
 
Immunitytheory
ImmunitytheoryImmunitytheory
Immunitytheory
Rakesh S
 
Bangun Datar Layang layang
Bangun Datar Layang layang Bangun Datar Layang layang
Bangun Datar Layang layang
Jihan Nabilah
 
Jihan Nabilah Ekayono Putri Persentasi Bab Cahaya Kelas 8
Jihan Nabilah Ekayono Putri  Persentasi Bab Cahaya Kelas 8Jihan Nabilah Ekayono Putri  Persentasi Bab Cahaya Kelas 8
Jihan Nabilah Ekayono Putri Persentasi Bab Cahaya Kelas 8
Jihan Nabilah
 

Destaque (13)

Social media
Social mediaSocial media
Social media
 
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell InspectionMAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution
 
USING FINANCIAL STATEMENTS INFORMATION
USING FINANCIAL STATEMENTS INFORMATIONUSING FINANCIAL STATEMENTS INFORMATION
USING FINANCIAL STATEMENTS INFORMATION
 
Online Marketing in Singapore - Hipponetwork
Online Marketing in Singapore - Hipponetwork Online Marketing in Singapore - Hipponetwork
Online Marketing in Singapore - Hipponetwork
 
Cdma
CdmaCdma
Cdma
 
KCB101 storyboard MK AN
KCB101 storyboard MK ANKCB101 storyboard MK AN
KCB101 storyboard MK AN
 
Immunitytheory
ImmunitytheoryImmunitytheory
Immunitytheory
 
Informe tecnico marzo 2016
Informe tecnico marzo 2016Informe tecnico marzo 2016
Informe tecnico marzo 2016
 
Bangun Datar Layang layang
Bangun Datar Layang layang Bangun Datar Layang layang
Bangun Datar Layang layang
 
8. Evangelina
8. Evangelina8. Evangelina
8. Evangelina
 
Jihan Nabilah Ekayono Putri Persentasi Bab Cahaya Kelas 8
Jihan Nabilah Ekayono Putri  Persentasi Bab Cahaya Kelas 8Jihan Nabilah Ekayono Putri  Persentasi Bab Cahaya Kelas 8
Jihan Nabilah Ekayono Putri Persentasi Bab Cahaya Kelas 8
 
20161126_Blender step2
20161126_Blender step220161126_Blender step2
20161126_Blender step2
 

Semelhante a Recommending Proper API Code Examples for Documentation Purpose

Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
NLJUG
 
automated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptxautomated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptx
Aditya274010
 
PRIME OOPSLA12 paper
PRIME OOPSLA12 paperPRIME OOPSLA12 paper
PRIME OOPSLA12 paper
Eran Yahav
 

Semelhante a Recommending Proper API Code Examples for Documentation Purpose (20)

Practices and tools for building better APIs
Practices and tools for building better APIsPractices and tools for building better APIs
Practices and tools for building better APIs
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
 
Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
 
Evaluating Recommended Applications
Evaluating Recommended ApplicationsEvaluating Recommended Applications
Evaluating Recommended Applications
 
API testing - Japura.pptx
API testing - Japura.pptxAPI testing - Japura.pptx
API testing - Japura.pptx
 
Survival Strategies: Building your first website for API documentation
Survival Strategies: Building your first website for API documentationSurvival Strategies: Building your first website for API documentation
Survival Strategies: Building your first website for API documentation
 
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, MicrosoftAPIs at Scale with TypeSpec by Mandy Whaley, Microsoft
APIs at Scale with TypeSpec by Mandy Whaley, Microsoft
 
Emulators as an Emerging Best Practice for API providers
Emulators as an Emerging Best Practice for API providersEmulators as an Emerging Best Practice for API providers
Emulators as an Emerging Best Practice for API providers
 
How to design effective APIs
How to design effective APIsHow to design effective APIs
How to design effective APIs
 
API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0
 
AWS API Framework Overview
AWS API Framework OverviewAWS API Framework Overview
AWS API Framework Overview
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
automated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptxautomated-automation-of-rest-apis.pptx
automated-automation-of-rest-apis.pptx
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptx
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptx
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
apidays LIVE LONDON - API Standards and Governance Platform by Nicoleta Stoica
apidays LIVE LONDON - API Standards and Governance Platform by Nicoleta Stoicaapidays LIVE LONDON - API Standards and Governance Platform by Nicoleta Stoica
apidays LIVE LONDON - API Standards and Governance Platform by Nicoleta Stoica
 
PRIME OOPSLA12 paper
PRIME OOPSLA12 paperPRIME OOPSLA12 paper
PRIME OOPSLA12 paper
 
Api clarity webinar
Api clarity webinarApi clarity webinar
Api clarity webinar
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Recommending Proper API Code Examples for Documentation Purpose

  • 1. Recommending Proper API Code Examples for Documentation Purpose Lee Wei Mar, Ye-Chi Wu, and Hewijin Christine Jiau DBSE Lab @ Inst. CCE & Dept. EE National Cheng Kung University (NCKU), Taiwan
  • 2. Outline • Introduction • Code Search Engines for Code Example Collection • The Proposed Methodology - PropER-Doc – Execution Process – Recommendation Assistants • Evaluation • Conclusion
  • 3. Introduction • Nowadays, object-oriented frameworks & libraries offer powerful APIs that facilitate programmers in accomplishing their works
  • 4. Introduction • Nowadays, object-oriented frameworks & libraries offer powerful APIs that facilitate programmers in accomplishing their works Power ↑ API Complexity ↑ Learning Barrier ↑
  • 5. Introduction • Nowadays, object-oriented frameworks & libraries offer powerful APIs that facilitate programmers in accomplishing their works Hamper Power ↑ API Complexity ↑ Learning Barrier ↑
  • 6. Introduction • Nowadays, object-oriented frameworks & libraries offer powerful APIs that facilitate programmers in accomplishing their works Hamper Power ↑ API Complexity ↑ Learning Barrier ↑ To ensure the facilitation, offering effective API learning resources is essential for API providers
  • 7. Introduction (cont.) • Code examples (CEs) are effective resources for API learning
  • 8. Introduction (cont.) • Code examples (CEs) are effective resources for API learning Eclipse SWT public class Snippet26 { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Combo combo = new Combo (shell, SWT.READ_ONLY); combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"}); Rectangle clientArea = shell.getClientArea (); combo.setBounds (clientArea.x, clientArea.y, 200, 200); shell.pack (); shell.open (); …. } Independent CE repository
  • 9. Introduction (cont.) • Code examples (CEs) are effective resources for API learning Eclipse SWT Eclipse JDT public class Snippet26 { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Combo combo = new Combo (shell, SWT.READ_ONLY); combo.setItems (new String [] {"Alpha", "Bravo", "Charlie"}); Rectangle clientArea = shell.getClientArea (); combo.setBounds (clientArea.x, clientArea.y, 200, 200); shell.pack (); shell.open (); …. } Independent CE repository Embedding CE in API reference
  • 10. Introduction (cont.) • Code examples (CEs) are effective resources for API learning Guide programmers to properly use API by demonstration
  • 11. Introduction (cont.) • Code examples (CEs) are effective resources for API learning Guide programmers to properly use API by demonstration • However, many APIs fail to offer sufficient CEs
  • 12. Introduction (cont.) • Code examples (CEs) are effective resources for API learning Guide programmers to properly use API by demonstration • However, many APIs fail to offer sufficient CEs API providers must invest large human effort for CE construction from scratch
  • 13. CSEs for Code Example Collection • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element
  • 14. CSEs for Code Example Collection • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element The signature of a specific API element is given as the query keyword
  • 15. CSEs for Code Example Collection • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element The signature of a specific API element is given as the query keyword • These files contain “client code” that demonstrates the use of the API element • The client code can be treated as “candidates” of CEs for documentation
  • 16. CSEs for Code Example Collection - Challenges • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element API providers must manually
  • 17. CSEs for Code Example Collection - Challenges • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element API providers must manually 1. Locate API usage code scattered in source files as candidates 2. Reorganize candidates according to different usages 3. Check appropriateness of candidates for documentation
  • 18. CSEs for Code Example Collection - Challenges • Code Search Engines (CSEs) are potentially useful in CE collection query API provider source files potentially use the API element API providers must manually 1. Locate API usage code scattered in source files as candidates 2. Reorganize candidates according to different usages 3. Check appropriateness of candidates for documentation These manual efforts must be reduced to make such practice applicable
  • 19. The Proposed Methodology – PropER-Doc • Proper code Example candidates Recommendation for Documentation – Use API element links to guide the recommendation from CSE results
  • 20. The Proposed Methodology – PropER-Doc • Proper code Example candidates Recommendation for Documentation – Use API element links to guide the recommendation from CSE results Links between API elements to indicate the joint use relationship • Structural Links from structural dependencies in API implementation • Conceptual Links from cross references in API documentation
  • 21. The Proposed Methodology – PropER-Doc • Proper code Example candidates Recommendation for Documentation – Use API element links to guide the recommendation from CSE results Links between API elements to indicate the joint use relationship • Structural Links from structural dependencies in API implementation • Conceptual Links from cross references in API documentation – Offer recommendation assistants for candidate inspection & selection
  • 22. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call Candidate significance candidate suggestion Annotation annotated candidates Candidate Recommendation
  • 23. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider
  • 24. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider The API provider gives a name of the API type that needs CEs
  • 25. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider The API provider gives a name of the API type that needs CEs The query is delegated to CSEs
  • 26. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates The API provider gives a name of the API type that needs CEs The query is delegated to CSEs • PropER-Doc collects candidates from CSE results • Candidate: a method implementation that refers targetType usage
  • 27. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call Candidate significance Annotation
  • 28. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call For each API call, annotate it with a Candidate significance significance degree Annotation 6 0 (relevant) (irrelevant)
  • 29. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call For each API call, annotate it with a Candidate significance significance degree Annotation 6 0 (relevant) (irrelevant) annotated candidates
  • 30. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call candidate suggestion Candidate significance Annotation annotated candidates Candidate Recommendation
  • 31. PropER-Doc Execution Process perform targetType query Candidate code search Collection API Provider candidates check API call candidate suggestion Candidate significance Annotation recommendation with assistants annotated candidates Candidate Recommendation
  • 32. Candidate Recommendation Four Recommendation Assistants are offered to guide the recommendation
  • 33. Candidate Recommendation Four Recommendation Assistants are offered to guide the recommendation [All candidates] Grouping for distinguishing API usages
  • 34. Candidate Recommendation Four Recommendation Assistants are offered to guide the recommendation [All candidates] [A selected group] Grouping for Diagramming API distinguishing API usages types interaction
  • 35. Candidate Recommendation Four Recommendation Assistants are offered to guide the recommendation [All candidates] [A selected group] [Candidates in a group] Grouping for Diagramming API Ranking based on distinguishing API usages types interaction appropriateness metrics
  • 36. Candidate Recommendation Four Recommendation Assistants are offered to guide the recommendation [All candidates] [A selected group] [Candidates in a group] [A selected candidate] Grouping for Diagramming API Ranking based on Presenting the distinguishing API usages types interaction appropriateness metrics candidate for inspection
  • 37. Recommendation - Clustering Grouping Diagramming Ranking Presenting [All candidates] – Distinguish different API usages
  • 38. Recommendation - Clustering Grouping Diagramming Ranking Presenting [All candidates] – Distinguish different API usages Rationale: In different usages, targetType tends to interact with different API types
  • 39. Recommendation - Clustering Grouping Diagramming Ranking Presenting [All candidates] – Distinguish different API usages Rationale: In different usages, targetType tends to interact with different API types • PropER-Doc extracts iTypes of each candidate – iTypes: the set of API types where targetType directly interacts with • Candidates with the same iTypes tend to demonstrate the same usage and are grouped together
  • 40. Recommendation - Clustering Grouping Diagramming Ranking Presenting [All candidates] – Distinguish different API usages Rationale: In different usages, targetType tends to interact with different API types • PropER-Doc extracts iTypes of each candidate – iTypes: the set of API types where targetType directly interacts with • Candidates with the same iTypes tend to demonstrate the same usage and are grouped together
  • 41. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection]
  • 42. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage
  • 43. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar
  • 44. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar – Box: API Type
  • 45. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar – Box: API Type – Edge / Label: interaction / API calls
  • 46. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar – Box: API Type – Edge / Label: interaction / API calls – API call popularity
  • 47. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar – Box: API Type – Edge / Label: interaction / API calls – API call popularity
  • 48. Recommendation - Clustering Grouping Diagramming Ranking Presenting [One group is selected for inspection] Use visual notation to summarize API type interaction of a specific usage • Visual Grammar – Box: API Type – Edge / Label: interaction / API calls – API call popularity • Selection of interested API calls for filtering candidates
  • 49. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A set of similar candidates demonstrating the same usage is chosen]
  • 50. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A set of similar candidates demonstrating the same usage is chosen] Which one is more appropriate for documentation and should be inspected first?
  • 51. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A set of similar candidates demonstrating the same usage is chosen] Define three appropriateness metrics to rank the candidates
  • 52. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A set of similar candidates demonstrating the same usage is chosen] Define three appropriateness metrics to rank the candidates Significance Density Cohesiveness Importance of referred API calls Portion of relevant API calls Degree of relevant call aggregation > > > more more representative comprehensible easier extraction Candidate Statements with significance degree 6 0
  • 53. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A set of candidates is chosen] Rank function: f(c) = Significance(c) + Density(c) + Cohesiveness(c)
  • 54. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A candidate is selected for inspection & CE construction]
  • 55. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A candidate is selected for inspection & CE construction] Highlight relevant code place to facilitate code inspection & extraction
  • 56. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A candidate is selected for inspection & CE construction] Highlight relevant code place to facilitate code inspection & extraction
  • 57. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A candidate is selected for inspection & CE construction] Highlight relevant code place to facilitate code inspection & extraction Important code blocks are highlighted
  • 58. Recommendation - Clustering Grouping Diagramming Ranking Presenting [A candidate is selected for inspection & CE construction] Highlight relevant code place to facilitate code inspection & extraction Key API elements are marked as bold Important code blocks are highlighted
  • 59. Evaluation • Objective: check PropER-Doc effectiveness on A. Distinguishing different API usages among candidates B. Suggesting proper candidates for CEs construction • Procedure 1. For an API type, manually identify its typical usages (U1) that need CEs 2. Use PropER-Doc to collect candidates and distinguish the API type usages (U2) 3. Map between U1 and U2 (objective A) 4. For each usage in U1, use PropER-Doc to select the top-ranked candidate 5. Evaluate the effort for constructing CE from top-ranked candidate (objective B) • Subject: ASTParser class (A complex API type in Eclipse JDT framework)
  • 60. Evaluation Result – Mapping Result U1 U2 (GID) Get AST from ICompilationUnit 1 Get AST from a string of class body 2 Get AST from a string of statements 3 Get AST from a string of expression 4 Get AST from ITypRoot 5 Get IJavaElement binding info. 6 Get AST from source code 7 Get ASTs from ICompilationUnits 8 Get AST from IClassFile 9
  • 61. Evaluation Result – Mapping Result U1 U2 (GID) • Mostly 1 : 1 mapping Get AST from ICompilationUnit 1 Get AST from a string of class body 2 Get AST from a string of statements 3 Get AST from a string of expression 4 Get AST from ITypRoot 5 Get IJavaElement binding info. 6 Get AST from source code 7 Get ASTs from ICompilationUnits 8 Get AST from IClassFile 9
  • 62. Evaluation Result – Mapping Result U1 U2 (GID) • Mostly 1 : 1 mapping Get AST from ICompilationUnit 1 – Confirm the effectiveness of the Get AST from a string of class body 2 grouping assistant in PropER-Doc Get AST from a string of statements 3 Get AST from a string of expression 4 Get AST from ITypRoot 5 Get IJavaElement binding info. 6 Get AST from source code 7 Get ASTs from ICompilationUnits 8 Get AST from IClassFile 9
  • 63. Evaluation Result – Mapping Result U1 U2 (GID) • Mostly 1 : 1 mapping Get AST from ICompilationUnit 1 – Confirm the effectiveness of the Get AST from a string of class body 2 grouping assistant in PropER-Doc Get AST from a string of statements 3 Get AST from a string of expression 4 • For the 3 : 1 mapping, the diagramming assistant is useful in Get AST from ITypRoot 5 distinguishing different usages Get IJavaElement binding info. 6 Get AST from source code 7 Get ASTs from ICompilationUnits 8 Get AST from IClassFile 9
  • 64. Evaluation Result – Mapping Result U1 U2 (GID) • Mostly 1 : 1 mapping Get AST from ICompilationUnit 1 – Confirm the effectiveness of the Get AST from a string of class body 2 grouping assistant in PropER-Doc Get AST from a string of statements 3 Get AST from a string of expression 4 • For the 3 : 1 mapping, the diagramming assistant is useful in Get AST from ITypRoot 5 distinguishing different usages Get IJavaElement binding info. 6 Get AST from source code 7 Get ASTs from ICompilationUnits 8 Get AST from IClassFile 9 The Grouping and Diagramming assistants are useful in distinguishing different API usages
  • 65. Evaluation Result – Constructing Effort U1 ∆Stmt (+/-) Coh. Get AST from ICompilationUnit 0/0 1.00 Get AST from a string of class body 0/0 1.00 Get AST from a string of statements 0/0 1.00 Get AST from a string of expression 4/0 1.00 Get AST from ITypRoot 0/1 1.00 Get IJavaElement binding info. 3/0 1.00 Get AST from source code 0/0 1.00 Get ASTs from ICompilationUnits 16 / 0 0.63 Get AST from IClassFile 0/0 1.00 ∆Stmt (+/-): #(extra statements) / #(missed statements) Coh.: Cohesiveness (between 0 and 1)
  • 66. Evaluation Result – Constructing Effort U1 ∆Stmt (+/-) Coh. • 5 of 9 top candidates can be Get AST from ICompilationUnit 0/0 1.00 directly used as CEs Get AST from a string of class body 0/0 1.00 Get AST from a string of statements 0/0 1.00 Get AST from a string of expression 4/0 1.00 Get AST from ITypRoot 0/1 1.00 Get IJavaElement binding info. 3/0 1.00 Get AST from source code 0/0 1.00 Get ASTs from ICompilationUnits 16 / 0 0.63 Get AST from IClassFile 0/0 1.00 ∆Stmt (+/-): #(extra statements) / #(missed statements) Coh.: Cohesiveness (between 0 and 1)
  • 67. Evaluation Result – Constructing Effort U1 ∆Stmt (+/-) Coh. • 5 of 9 top candidates can be Get AST from ICompilationUnit 0/0 1.00 directly used as CEs Get AST from a string of class body 0/0 1.00 Get AST from a string of statements 0/0 1.00 • Only 1 top candidate misses 1 statement for CE construction Get AST from a string of expression 4/0 1.00 – Top candidates contains almost all Get AST from ITypRoot 0/1 1.00 required API calls for CE construction Get IJavaElement binding info. 3/0 1.00 Get AST from source code 0/0 1.00 Get ASTs from ICompilationUnits 16 / 0 0.63 Get AST from IClassFile 0/0 1.00 ∆Stmt (+/-): #(extra statements) / #(missed statements) Coh.: Cohesiveness (between 0 and 1)
  • 68. Evaluation Result – Constructing Effort U1 ∆Stmt (+/-) Coh. • 5 of 9 top candidates can be Get AST from ICompilationUnit 0/0 1.00 directly used as CEs Get AST from a string of class body 0/0 1.00 Get AST from a string of statements 0/0 1.00 • Only 1 top candidate misses 1 statement for CE construction Get AST from a string of expression 4/0 1.00 – Top candidates contains almost all Get AST from ITypRoot 0/1 1.00 required API calls for CE construction Get IJavaElement binding info. 3/0 1.00 Get AST from source code 0/0 1.00 • High cohesiveness in all top candidates Get ASTs from ICompilationUnits 16 / 0 0.63 – Effort for relevant code extraction Get AST from IClassFile 0/0 1.00 from top candidates is quite low ∆Stmt (+/-): #(extra statements) / #(missed statements) Coh.: Cohesiveness (between 0 and 1)
  • 69. Evaluation Result – Constructing Effort U1 ∆Stmt (+/-) Coh. • 5 of 9 top candidates can be Get AST from ICompilationUnit 0/0 1.00 directly used as CEs Get AST from a string of class body 0/0 1.00 Get AST from a string of statements 0/0 1.00 • Only 1 top candidate misses 1 statement for CE construction Get AST from a string of expression 4/0 1.00 – Top candidates contains almost all Get AST from ITypRoot 0/1 1.00 required API calls for CE construction Get IJavaElement binding info. 3/0 1.00 Get AST from source code 0/0 1.00 • High cohesiveness in all top candidates Get ASTs from ICompilationUnits 16 / 0 0.63 – Effort for relevant code extraction Get AST from IClassFile 0/0 1.00 from top candidates is quite low PoperER-Doc suggests high quality candidates for CEs construction
  • 70. Conclusion • PropER-Doc is proposed to assist API providers in constructing proper API code examples using code search engines 1. Candidate grouping algorithm 2. API-type interaction diagram 3. Metrics-based ranking mechanism
  • 71. Conclusion • PropER-Doc is proposed to assist API providers in constructing proper API code examples using code search engines 1. Candidate grouping algorithm Distinguish different API usages 2. API-type interaction diagram 3. Metrics-based ranking mechanism
  • 72. Conclusion • PropER-Doc is proposed to assist API providers in constructing proper API code examples using code search engines 1. Candidate grouping algorithm Distinguish different API usages 2. API-type interaction diagram Inspect specific usage & filter candidates 3. Metrics-based ranking mechanism
  • 73. Conclusion • PropER-Doc is proposed to assist API providers in constructing proper API code examples using code search engines 1. Candidate grouping algorithm Distinguish different API usages 2. API-type interaction diagram Inspect specific usage & filter candidates 3. Metrics-based ranking mechanism Select high quality candidates
  • 74. Conclusion • PropER-Doc is proposed to assist API providers in constructing proper API code examples using code search engines 1. Candidate grouping algorithm Distinguish different API usages 2. API-type interaction diagram Inspect specific usage & filter candidates 3. Metrics-based ranking mechanism Select high quality candidates • Evaluation on Eclipse JDT framework has been conducted to confirm the effectiveness of PropER-Doc
  • 75. Thank You Lee Wei Mar (馬立偉) lwmar@nature.ee.ncku.edu.tw Database and Software Engineering Laboratory, Institute of Computer and Communication Engineering & Department of Electrical Engineering, National Cheng Kung University, Tainan, Taiwan