SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Making Sense of Online
Code Snippets
Siddharth Subramanian, Reid Holmes
University of Waterloo
2
Indexes millions of random code
snippets from the internet
Public
Code on
the Internet
Traditional Code
Search
crawler
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
Curated Code
Search
3
Indexes millions of random code
snippets from the internet
Indexes a limited set of good
quality code snippets
Public
Code on
the Internet
Traditional Code
Search
crawler
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
crawler
Code Search Challenges
Code Search Challenges
5
chrono -Type unknown!
run()- 20 different methods
 java.util.TimerTask.run()
 android.os.HandlerThread.run()
 …
start()- 26 different methods
 android.media.MediaPlayer.start()
 android.animation.Animator.start()
 …
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
Code Search Challenges
PROBLEMS WITH LEXICAL SEARCH
6
 Code is treated as plain-text
 Underlying API linkage is lost
 Method name collisions
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
Code Search Challenges
7
chrono -android.widget.Chronometer
run()-java.lang.Runnable.run()
start()- android.widget.Chronometer.start()
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
Code Search Challenges
PROBLEMS WITH LEXICAL SEARCH PROBLEMS WITH PARSING CODE
 Code snippets are often incomplete
 Missing class declarations
 Missing method declarations
 Incomplete code fragments
8
 Code is treated as plain-text
 Underlying API linkage is lost
 Method name collisions
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
Approach
Approach
[Parnin et. al., Georgia Tech, Tech. Rep., 2012]
Approach
SnipParse
1
Code Snippet Parser
Approach
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13 12
SnipParse
Curated Snippet
Repository
• Android Types
• Android Methods
1
Code Snippet Parser
Approach
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13 13
SnipParse
Curated Snippet
Repository
• Android Types
• Android Methods
1
CodeHunter
2
Code Search
Web Interface
Code Snippet Parser
Summary
 Enabling Curated Search
 http://awenda.cs.uwaterloo.ca/snippet/
https://cs.uwaterloo.ca/~rtholmes/papers/msr_2013_subramanian.pdf
14
MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES
MSR '13
SnipParse
Curated Snippet
Repository
• Android Types
• Android Methods
1
CodeHunter
Code Search
Web Interface
Code Snippet Parser

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Empfohlen (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Making Sense of Online Code Snippets

  • 1. Making Sense of Online Code Snippets Siddharth Subramanian, Reid Holmes University of Waterloo
  • 2. 2 Indexes millions of random code snippets from the internet Public Code on the Internet Traditional Code Search crawler MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13
  • 3. Curated Code Search 3 Indexes millions of random code snippets from the internet Indexes a limited set of good quality code snippets Public Code on the Internet Traditional Code Search crawler MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13 crawler
  • 5. Code Search Challenges 5 chrono -Type unknown! run()- 20 different methods  java.util.TimerTask.run()  android.os.HandlerThread.run()  … start()- 26 different methods  android.media.MediaPlayer.start()  android.animation.Animator.start()  … MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13
  • 6. Code Search Challenges PROBLEMS WITH LEXICAL SEARCH 6  Code is treated as plain-text  Underlying API linkage is lost  Method name collisions MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13
  • 7. Code Search Challenges 7 chrono -android.widget.Chronometer run()-java.lang.Runnable.run() start()- android.widget.Chronometer.start() MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13
  • 8. Code Search Challenges PROBLEMS WITH LEXICAL SEARCH PROBLEMS WITH PARSING CODE  Code snippets are often incomplete  Missing class declarations  Missing method declarations  Incomplete code fragments 8  Code is treated as plain-text  Underlying API linkage is lost  Method name collisions MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13
  • 10. Approach [Parnin et. al., Georgia Tech, Tech. Rep., 2012]
  • 12. Approach MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13 12 SnipParse Curated Snippet Repository • Android Types • Android Methods 1 Code Snippet Parser
  • 13. Approach MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13 13 SnipParse Curated Snippet Repository • Android Types • Android Methods 1 CodeHunter 2 Code Search Web Interface Code Snippet Parser
  • 14. Summary  Enabling Curated Search  http://awenda.cs.uwaterloo.ca/snippet/ https://cs.uwaterloo.ca/~rtholmes/papers/msr_2013_subramanian.pdf 14 MAKING SENSE OF ONLINE CODE SNIPPETS - SIDDHARTH SUBRAMANIAN, REID HOLMES MSR '13 SnipParse Curated Snippet Repository • Android Types • Android Methods 1 CodeHunter Code Search Web Interface Code Snippet Parser

Hinweis der Redaktion

  1. Good morning everybody, I’m Siddharth Subramanian and I’m here to explain our submission to the MSR Challenge, which was work done in collaboration with Reid Holmes at the University of Waterloo. We built a system that helps developers better find API usage examples from the internet. We do so by extracting structural information hidden in code snippets on to guide code search and to construct a repository of curated source code examples from StackOVerflow.
  2. Developers frequently reuse source code or search for examples to learn about a new API. In the process, they frequently use websites like Google code or Krugle to look for examples. How do these code search engines work? They index millions of code snippets that are publicly available on the internet. However, a lot of these code snippets are of poor quality and there is no assurance if they would actually work. To overcome this issue, we built a curated code search engine that searches through code snippets in accepted answers on stack overflow. This way, developers can search for code examples with have a guarantee that the results they get would actually work.What it does? Problem? What we do? Why android?
  3. Developers frequently reuse source code or search for examples to learn about a new API. In the process, they frequently use websites like Google code or Krugle to look for examples. How do these code search engines work? They index millions of code snippets that are publicly available on the internet. However, a lot of these code snippets are of poor quality and there is no assurance if they would actually work. To overcome this issue, we built a curated code search engine that searches through code snippets in accepted answers on stack overflow. This way, developers can search for code examples with have a guarantee that the results they get would actually work.What it does? Problem? What we do? Why android?
  4. However, lexically searching through source code is lossy. Consider the following code snippet from a post on SO. The type declaration of the chrono object is missing, so we do not know which particular methods run(), setbase() and start() methods are from the android API are being called. The android API has 20 different methods named run() and 26 methods named start() and It is not clear which ones are being called in this context. However, on parsing and analysing the code snippet, we can infer that the chrono object belongs to android.widget.chronometer type and the method run() being overridden is the ___ and start is ___. But since stack overflow deals with code snippets, parsing them is difficult.
  5. However, lexically searching through source code is lossy. Consider the following code snippet from a post on SO. The type declaration of the chrono object is missing, so we do not know which particular methods run(), setbase() and start() methods are from the android API are being called. The android API has 20 different methods named run() and 26 methods named start() and It is not clear which ones are being called in this context. However, on parsing and analysing the code snippet, we can infer that the chrono object belongs to android.widget.chronometer type and the method run() being overridden is the ___ and start is ___. But since stack overflow deals with code snippets, parsing them is difficult.
  6. However, lexically searching through source code is lossy. Consider the following code snippet from a post on SO. The type declaration of the chrono object is missing, so we do not know which particular methods run(), setbase() and start() methods are from the android API are being called. The android API has 20 different methods named run() and 26 methods named start() and It is not clear which ones are being called in this context. However, on parsing and analysing the code snippet, we can infer that the chrono object belongs to android.widget.chronometer type and the method run() being overridden is the ___ and start is ___. But since stack overflow deals with code snippets, parsing them is difficult.
  7. However, lexically searching through source code is lossy. Consider the following code snippet from a post on SO. The type declaration of the chrono object is missing, so we do not know which particular methods run(), setbase() and start() methods are from the android API are being called. The android API has 20 different methods named run() and 26 methods named start() and It is not clear which ones are being called in this context. However, on parsing and analysing the code snippet, we can infer that the chrono object belongs to android.widget.chronometer type and the method run() being overridden is the ___ and start is ___. But since stack overflow deals with code snippets, parsing them is difficult.
  8. However, lexically searching through source code is lossy. Consider the following code snippet from a post on SO. The type declaration of the chrono object is missing, so we do not know which particular methods run(), setbase() and start() methods are from the android API are being called. The android API has 20 different methods named run() and 26 methods named start() and It is not clear which ones are being called in this context. However, on parsing and analysing the code snippet, we can infer that the chrono object belongs to android.widget.chronometer type and the method run() being overridden is the ___ and start is ___. But since stack overflow deals with code snippets, parsing them is difficult.
  9. We built a tool called snipparse that can parse through incomplete java source code snippets and extract structural information from them. We populated results using this tool on the posts belonging to the android framework since previous research by Parnin and others has shown that SO discussions cover a significant portion of the android API. We used this tool to build a curated source code repository where code is indexed based on the types and methods that are being used in them. This repository is made accessible through a web interface called codehunter that allows users search for precise API usage examples.
  10. We built a tool called snipparse that can parse through incomplete java source code snippets and extract structural information from them. We populated results using this tool on the posts belonging to the android framework since previous research by Parnin and others has shown that SO discussions cover a significant portion of the android API. We used this tool to build a curated source code repository where code is indexed based on the types and methods that are being used in them. This repository is made accessible through a web interface called codehunter that allows users search for precise API usage examples.
  11. We built a tool called snipparse that can parse through incomplete java source code snippets and extract structural information from them. We populated results using this tool on the posts belonging to the android framework since previous research by Parnin and others has shown that SO discussions cover a significant portion of the android API. We used this tool to build a curated source code repository where code is indexed based on the types and methods that are being used in them. This repository is made accessible through a web interface called codehunter that allows users search for precise API usage examples.
  12. We built a tool called snipparse that can parse through incomplete java source code snippets and extract structural information from them. We populated results using this tool on the posts belonging to the android framework since previous research by Parnin and others has shown that SO discussions cover a significant portion of the android API. We used this tool to build a curated source code repository where code is indexed based on the types and methods that are being used in them. This repository is made accessible through a web interface called codehunter that allows users search for precise API usage examples.
  13. We built a tool called snipparse that can parse through incomplete java source code snippets and extract structural information from them. We populated results using this tool on the posts belonging to the android framework since previous research by Parnin and others has shown that SO discussions cover a significant portion of the android API. We used this tool to build a curated source code repository where code is indexed based on the types and methods that are being used in them. This repository is made accessible through a web interface called codehunter that allows users search for precise API usage examples.
  14. To summarize, we built a tool that can identify structy