Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ON THE USE OF CONTEXT IN
RECOMMENDING EXCEPTION
HANDLING CODE EXAMPLES
Mohammad Masudur Rahman, Chanhcal K. Roy
Department...
EXCEPTION HANDLING
2
SoftwareResearchLab,UofS
Normal
program
code
Exception
handler
code
EXCEPTION HANDLING STATISTICS
3
SoftwareResearchLab,UofS
70%
30%
Ineffective
Effective
32 applications Exception handling
...
TRADITIONAL CODE SEARCH ENGINES
4
SoftwareResearchLab,UofS
(2) Thousands
of results
(1) No logical ties with IDE
(3) Only ...
IDE SUPPORT FOR EXCEPTION HANDLING
5
(6) Only adds a generic handler
which is NOT much helpful for
effective exception han...
SURFEXAMPLE: CONTEXT-AWARE CODE EXAMPLE
RECOMMENDER FOR EXCEPTION HANDLING
6
SurfExample
MOTIVATING EXAMPLE
7
SoftwareResearchLab,UofS
Context code
Recommended code example
PROPOSED CONTEXT-AWARE CODE EXAMPLE
RECOMMENDER FOR EXCEPTION HANDLING
8
SoftwareResearchLab,UofS
Start
a
b
c
d e End
GitH...
PROPOSED CONTEXT-AWARE CODE EXAMPLE
RECOMMENDER FOR EXCEPTION HANDLING
 Distinguishing Features (3)
 Graph-based structu...
PROPOSED METRICS
 Structural Relevance (Rstr)
 API Object Match (AOM)
 Field Access Match (FAM)
 Method Invocation Mat...
EXPERIMENT OVERVIEW
11
SoftwareResearchLab,UofS
65 exceptions +
context code
700+ GitHub code
repositories
4400 code examp...
RESULTS ON DIFFERENT RANKING ASPECTS
12
SoftwareResearchLab,UofS
Ranking Aspects Metrics Top 5 Top 10 Top 15
Structure (Rs...
INFLUENCE OF DIFFERENT RANKING ASPECTS
13
SoftwareResearchLab,UofS
COMPARISON WITH EXISTING APPROACHES
14
SoftwareResearchLab,UofS
Recommender Metrics Top 5 Top 10 Top 15
Barbosa et al.,
SB...
MEAN PRECISION VS. RECALL CURVES
15
SoftwareResearchLab,UofS
THREATS TO VALIDITY
 Subjective bias in the gold set development
 Subjected to the performance of GitHub Code
Search fea...
CONCLUSION
 SurfExample combines
 Graph-based structural features
 Lexical features
 Heuristic estimate of exception h...
FUTURE WORK
 Applicability or reusability of an example for
exception handling for current context
 More directed suppor...
THANK YOU! QUESTIONS?
19
SoftwareResearchLab,UofS
SPECIAL THANKS TO
PROVOCATIVE STATEMENTS
 Should the checked exceptions be removed from
Java? Was it a mistake?
 Who should be responsible...
REFERENCES
[1] B. Cabral and P. Marques. Exception Handling: A Field Study in Java and .NET. In Proc. ECOOP, pages
151–175...
Upcoming SlideShare
Loading in …5
×

SurfExample- Recommendation of Exception Handling Code Examples

179 views

Published on

Studies show that software developers often either misuse exception handling features or use them inefficiently, and such a practice may lead an undergoing software project to a fragile, insecure and non-robust application system. In this paper, we propose a context-aware code recommendation approach that recommends exception handling code examples from a number of popular open source code repositories hosted at GitHub. It collects the code examples exploiting GitHub code search API, and then analyzes, filters and ranks them against the code under development in the IDE by leveraging not only the structural (i.e., graph-based) and lexical features but also the heuristic quality measures of exception handlers in the examples. Experiments with 4,400 code examples and 65 exception handling scenarios as well as comparisons with four existing approaches show that the proposed approach is highly promising.

Published in: Education
  • Be the first to comment

  • Be the first to like this

SurfExample- Recommendation of Exception Handling Code Examples

  1. 1. ON THE USE OF CONTEXT IN RECOMMENDING EXCEPTION HANDLING CODE EXAMPLES Mohammad Masudur Rahman, Chanhcal K. Roy Department of Computer Science University of Saskatchewan IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM 2014), Victoria, Canada
  2. 2. EXCEPTION HANDLING 2 SoftwareResearchLab,UofS Normal program code Exception handler code
  3. 3. EXCEPTION HANDLING STATISTICS 3 SoftwareResearchLab,UofS 70% 30% Ineffective Effective 32 applications Exception handling Statistics (Cabral and Marques, ECOOP 2007) 70% of the handlers are generic or ineffective
  4. 4. TRADITIONAL CODE SEARCH ENGINES 4 SoftwareResearchLab,UofS (2) Thousands of results (1) No logical ties with IDE (3) Only keyword-matching search (4) No query support (5) No support for exception handling
  5. 5. IDE SUPPORT FOR EXCEPTION HANDLING 5 (6) Only adds a generic handler which is NOT much helpful for effective exception handling
  6. 6. SURFEXAMPLE: CONTEXT-AWARE CODE EXAMPLE RECOMMENDER FOR EXCEPTION HANDLING 6
  7. 7. SurfExample MOTIVATING EXAMPLE 7 SoftwareResearchLab,UofS Context code Recommended code example
  8. 8. PROPOSED CONTEXT-AWARE CODE EXAMPLE RECOMMENDER FOR EXCEPTION HANDLING 8 SoftwareResearchLab,UofS Start a b c d e End GitHub Code Search Source Files Metrics Calculator Corpus Score Calculator Rank Manager Code search query Context code Ranked code examples Code examples Server Client
  9. 9. PROPOSED CONTEXT-AWARE CODE EXAMPLE RECOMMENDER FOR EXCEPTION HANDLING  Distinguishing Features (3)  Graph-based structural relevance  Static relationship and data dependency graph (Nguyen et al., ESEC/FSE 2009)  Graph structure matching  Handler quality Paradigm  Novel idea to ensure quality of exception handlers  Based on readability, count & quality estimate of the handler actions  Seamless integration of dataset  Exploits GitHub API for data collection  Hundreds of popular and mature open source projects from Eclipse, Apache and others 9 SoftwareResearchLab,UofS
  10. 10. PROPOSED METRICS  Structural Relevance (Rstr)  API Object Match (AOM)  Field Access Match (FAM)  Method Invocation Match (MIM) (Holmes and Murphy, ICSE 2005)  Data Dependency Match (DDM)  Lexical Relevance (Rlex)  Cosine Similarity (Takuya and Masuhara, SUITE 2011)  Code Clone Measure (Roy and Cordy, ICPC 2008)  Exception Handler Quality (Qehc)  Readability (RA) (Buse and Weimer, TSE 2010)  Average Handler Actions (AHA)  Handler to Code Ratio (HCR) 10 SoftwareResearchLab,UofS
  11. 11. EXPERIMENT OVERVIEW 11 SoftwareResearchLab,UofS 65 exceptions + context code 700+ GitHub code repositories 4400 code examples Gold set solutions (50-60 work hours) Peers
  12. 12. RESULTS ON DIFFERENT RANKING ASPECTS 12 SoftwareResearchLab,UofS Ranking Aspects Metrics Top 5 Top 10 Top 15 Structure (Rstr) MAPK Recall PEH 38.07% 50.00% 69.23% 33.84% 61.93% 75.38% 32.64% 69.32% 81.54% Content (Rlex) MAPK Recall PEH 35.00% 45.45% 66.15% 33.85% 63.63% 75.38% 33.08% 70.45% 81.54% {Structure (Rstr), Content (Rlex)} MAPK Recall PEH 43.08% 51.70% 69.23% 38.69% 66.48% 75.38% 37.33% 74.43% 81.54% {Structure (Rstr), Content (Rlex), Quality (Qehc)} MAPK Recall PEH 41.92% 57.39% 73.85% 39.92% 68.75% 81.54% 38.64% 76.70% 86.15% [ MAPK = Mean Average Precision at K, PEH= % of exceptions handled]
  13. 13. INFLUENCE OF DIFFERENT RANKING ASPECTS 13 SoftwareResearchLab,UofS
  14. 14. COMPARISON WITH EXISTING APPROACHES 14 SoftwareResearchLab,UofS Recommender Metrics Top 5 Top 10 Top 15 Barbosa et al., SBES, 2012 MAPK Recall PEH 16.15% 16.47% 27.69% 14.69% 25.57% 38.46% 13.72% 31.25% 44.62% Holmes & Murphy, ICSE, 2005 MAPK Recall PEH 4.62% 11.36% 24.62% 2.31% 21.59% 38.46% 2.31% 27.84% 47.69% Takuya & Masuhara, SUITE, 2011 MAPK Recall PEH 21.54% 15.34% 33.85% 20.51% 27.27% 47.69% 19.74% 30.68% 47.69% Bajracharya et al., SUITE, 2009 MAPK Recall PEH 8.46% 10.80% 18.46% 7.95% 15.91% 27.69% 6.41% 19.32% 30.77% Proposed approach MAPK Recall PEH 41.92% 57.39% 73.85% 39.92% 68.75% 81.54% 38.64% 76.70% 86.15% [ MAPK = Mean Average Precision at K, PEH= % of exceptions handled]
  15. 15. MEAN PRECISION VS. RECALL CURVES 15 SoftwareResearchLab,UofS
  16. 16. THREATS TO VALIDITY  Subjective bias in the gold set development  Subjected to the performance of GitHub Code Search feature  Limited size of dynamic corpus for recommendation  Limited number of exceptions for experiments 16 SoftwareResearchLab,UofS
  17. 17. CONCLUSION  SurfExample combines  Graph-based structural features  Lexical features  Heuristic estimate of exception handler quality  SurfExample found promising based on experimental results  General-purpose code example recommender not much effective 17 SoftwareResearchLab,UofS
  18. 18. FUTURE WORK  Applicability or reusability of an example for exception handling for current context  More directed support– exception to be thrown or to be handled 18 SoftwareResearchLab,UofS
  19. 19. THANK YOU! QUESTIONS? 19 SoftwareResearchLab,UofS SPECIAL THANKS TO
  20. 20. PROVOCATIVE STATEMENTS  Should the checked exceptions be removed from Java? Was it a mistake?  Who should be responsible for exception handling, language designers or software developers? 20 SoftwareResearchLab,UofS
  21. 21. REFERENCES [1] B. Cabral and P. Marques. Exception Handling: A Field Study in Java and .NET. In Proc. ECOOP, pages 151–175, 2007 [2] S. Bajracharya, J. Ossher, and C. Lopes. Sourcerer: An Internet-Scale Software Repository. In Proc. SUITE, pages 1–4, 2009. [3] E. A. Barbosa, A. Garcia, and M. Mezini. Heuristic Strategies for Recommendation of Exception Handling Code. In Proc. SBES, pages 171–180, 2012. [4] R. P. L. Buse and W. R. Weimer. Learning a Metric for Code Readability. TSE, 36(4):546–558, 2010. [5] R. Holmes and G. C. Murphy. Using Structural Context to Recommend Source Code Examples. In Proc. ICSE, pages 117–125, 2005 [6] T. T. Nguyen, H. A. Nguyen, N. H. Pham, J. M. Al-Kofahi, and T. N. Nguyen. Graph-based Mining of Multiple Object Usage Patterns. In Proc. ESEC/FSE, pages 383–392, 2009. [7] M. P. Robillard and G. C. Murphy. Static Analysis to Support the Evolution of Exception Structure in Object-Oriented Systems. TOSEM, 12(2):191–221, 2003. [8] C. K. Roy and J. R. Cordy. NICAD: Accurate Detection of Near-Miss Intentional Clones Using Flexible Pretty-Printing and Code Normalization. In Proc. ICPC, pages 172–181, 2008. [9] H. Shah, C. Görg, and M. J. Harrold. Visualization of Exception Handling Constructs to Support Program Understanding. In Proc. SoftVis, pages 19–28, 2008. [10] W. Takuya and H. Masuhara. A Spontaneous Code Recommendation Tool Based on Associative Search. In Proc. SUITE, pages 17–20, 2011 [11] Exception Handling Principles. URL http://howtodoinjava.com/2013/04/04/java-exception-handling-best- practices. [12] Best Practices for Exception Handling. URL https://www.ibm.com/developerworks/library/j-ejbexcept 21 SoftwareResearchLab,UofS

×