Your SlideShare is downloading. ×
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Programming by imitation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Programming by imitation

195

Published on

The research project I worked at while I visited MIT

The research project I worked at while I visited MIT

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
195
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PROGRAMMING BY IMITATION Mario Sangiorgio Kuat Yessenov Armando Solar-Lezama
  • 2. PLUG-IN ARCHITECTURE New feature New feature New feature Application Programming Interface Core System
  • 3. ISSUES Integrating with the system is hardFeatures need only a Integration requires tiny part of the API several steps
  • 4. GOALImprove productivity by synthesizing the glue code.Programmers should only care about their features.
  • 5. IDEAS Different plug-ins may need the same functionality from the framework Why don’t we imitate what existing plug-ins are doing?
  • 6. APPROACH1. Show our tool what you want to do2. Generate the code that imitates that feature3. Put everything together and add your own code
  • 7. RECORDING THE EXECUTION Keeping track of everything the application does
  • 8. TRACE ANALYSISUnderstanding which elements are related to the feature
  • 9. CODE SYNTHESISGenerating the code imitating the feature
  • 10. TRACE COLLECTION
  • 11. DATA DRIVEN APPROACHLightweight instrumentation of method calls and field accesses in relevant classes
  • 12. TRACESByte-code level Describe everything is going on in the application
  • 13. TRACESByte-code level Describe everything is going on in the application Have a lot of information (Up to several MBs/sec)
  • 14. WE NEED ABSTRACTION!
  • 15. TRACE ANALYSIS
  • 16. PACKAGE DEPENDENCY GRAPH A B
  • 17. PACKAGE DEPENDENCY GRAPH packages A B
  • 18. PACKAGE DEPENDENCY GRAPH packages A B call from a method in package A to a method declared in package B
  • 19. ISOLATION OF FRAMEWORK CODE C A B D E The structure of the graph reflects the high level structure of the application
  • 20. ISOLATION OF FRAMEWORK CODE C A B D E PLUG-IN The structure of the graph reflects the high level structure of the application
  • 21. ISOLATION OF FRAMEWORK CODE C A B D E PLUG-IN FRAMEWORK The structure of the graph reflects the high level structure of the application
  • 22. PLUG-IN CODE Code called only from other plug-in packages orA through special mechanisms (e.g. Reflection) EPLUG-IN
  • 23. FRAMEWORK CODE C Called by plug-in code and only calls methods B D declared in framework packagesFRAMEWORK
  • 24. EXAMPLEimport org.gjt.sp.jedit.buffer.JEditBuffer;import org.gjt.sp.jedit.buffer.FoldHandler;public class JavaFold extends FoldHandler { /* ... */ @Override public int getFoldLevel(JEditBuffer buffer, int lineIndex, Segment segment) { buffer.getLineText(lineIndex, segment); /* ... */ }}
  • 25. EXAMPLE The plug-in extendsimport org.gjt.sp.jedit.buffer.JEditBuffer;import org.gjt.sp.jedit.buffer.FoldHandler; a framework classpublic class JavaFold extends FoldHandler { /* ... */ @Override public int getFoldLevel(JEditBuffer buffer, int lineIndex, Segment segment) { buffer.getLineText(lineIndex, segment); /* ... */ }}
  • 26. EXAMPLE The plug-in extendsimport org.gjt.sp.jedit.buffer.JEditBuffer;import org.gjt.sp.jedit.buffer.FoldHandler; a framework classpublic class JavaFold extends FoldHandler { /* ... */ This is the method used @Override by the framework public int getFoldLevel(JEditBuffer buffer, int lineIndex, Segment segment) { buffer.getLineText(lineIndex, segment); /* ... */ }}
  • 27. EXAMPLE The plug-in extendsimport org.gjt.sp.jedit.buffer.JEditBuffer;import org.gjt.sp.jedit.buffer.FoldHandler; a framework classpublic class JavaFold extends FoldHandler { /* ... */ This is the method used @Override by the framework public int getFoldLevel(JEditBuffer buffer, int lineIndex, Segment segment) { buffer.getLineText(lineIndex, segment); /* ... */} } The plug-in uses the framework
  • 28. REMOVING IMPLEMENTATION DETAILS C A B D E PLUG-IN FRAMEWORK We are interested in code crossing the boundaries
  • 29. A COMPACT REPRESENTATION
  • 30. SO FAR We know the plug-in uses the frameworkWe don’t know the precise method we need
  • 31. SO FAR We know the plug-in uses the frameworkWe don’t know the precise method we need WE SHOULD GUIDE THE USERDISCOVERY OF THE METHODS HE NEEDS
  • 32. CALL TREES ABSTRACTION
  • 33. CALL TREES ABSTRACTION
  • 34. TRACE EXPLORATION• We still have too many call trees• Users should search the framework calls in term of the high level features they see• The framework may use a different terminology
  • 35. TRACE EXPLORATION• We still have too many call trees• Users should search the framework calls in term of the high level features they see• The framework may use a different terminology USERS SHOULD BE ABLE TO SEARCH FOR THE MOST RELEVANT CALL TREES
  • 36. FEATURE SEARCH High Level Query Search in class names, methods and documentation Matching call trees
  • 37. SEARCH RESULT
  • 38. CALL TREE EXPLORATION The user wants The user doesn’t want See matching methods Redundant information (loops)Know how to reach them Sub-trees with only plug-in code Navigate the tree Framework implementation See the documentation details
  • 39. INTERACTIVE VISUALIZATION
  • 40. INTERACTIVE VISUALIZATIONCompact representation of the call tree
  • 41. INTERACTIVE VISUALIZATION DocumentationCompact representation of the call tree
  • 42. INTERACTIVE VISUALIZATION DocumentationCompact representation of the call tree Framework code
  • 43. TRACE MATCHING
  • 44. THE SHORT TRACE IS NOT ENOUGHIt contains the code that causes the feature to execute It misses all the setup code WE NEED TO GET INFORMATION FROM A LARGER DATABASE
  • 45. THE COMPLETE TRACEContains the compete execution of several runs of the application, exercising different featuresThis trace contains all the information we need to properly setup the plug-in
  • 46. MATCHINGA demo and a complete trace match if: the corresponding method handles match call events in the complete trace are covered by the same package we found in the demo tracecalls that in demo share a receiver do it also in the complete trace
  • 47. CODE SYNTHESIS
  • 48. SYNTHESIS THROUGH SLICING We look for the minimal set of instruction (slice) that can reproduce the matched trace The result is code with holes that should be filled by the user to integrate the features he needs
  • 49. THANK YOU!

×