Eclipse Code
Recommenders




 “IDE 2.0”
 Collective Intelligence in Software Development
 Leveraging the Wisdom of the Crowds
 Marcel Bruch
Eclipse Code Recommenders
 All Frameworks          Code

Code




                                Eclipse Code Recommenders
                                – do what most people do!   (where appropriate)




Developers Who Called “new        Text()” Method Also Called

         setText()          addListener()        setLayout()              setFont()
           89%                   53%                 99%                      35%




  What Do Developers Ultimately Override After Extending This Class?
       100 % overwrote
       PreferencePage.createContents()

       96 % overwrote
       PreferencePage.performOk()

       5 % overwrote
       PreferencePage.performCancel()
“Other developers frequently bought used the following methods…”

INTELLIGENT CODE COMPLETION
Code Completion…




What does the developer need, i.e., which methods
 should the code completion present to the user?
All 164 Methods of Text ?
JButton? 381 Methods.
Code Completion…




What does the developer need, i.e., which methods
 should the code completion present to the user?
Intelligent Code Completion




  … or just the three missing ones?
Eclipse Code Recommenders
Why just one when you can have templates…
How it works – in a nutshell…


                   Framework                          If you
                                                    extend A,
                                                    you should
                                                     call B.c

  Framework                       Framework        Recommender
                       …                              Model
Instantiation 1                 Instantiation n



 extract facts about how the framework is reused




 <extends:A>                    <extends:A>
<overrides:A.b>                <overrides:A.d>
                       …         <calls:B.c>
  <calls:B.c>
       …                              …
                                                      Mining
How it works – in a nutshell…
How it works – in a nutshell…




Observation        Recommendations
“What do Developers Ultimately buy override after extending this class?”

USAGE-DRIVEN JAVADOCS
Some Facts About The
     Documentation of Overridable Methods




overridable                             2074



overridden      623
What Clients Do With Your API…




    overridden                                                                                623



 documented*                    155                                                           478




*: documented as overridable by using phrases like “clients may/should/must override/extend this method”
What documentation would you expect when
         subclassing a Dialog?
What Javadoc gives to you…


A dialog is a specialized window used for narrow-focused
communication with the user.

Dialogs are usually modal. Consequently, it is generally
bad practice to open a dialog without a parent. A modal
dialog without a parent is not prevented from
disappearing behind the application's other
        But what are the
windows, making it very confusing for the user.

If there is more than one modal dialog is open the
second one should be parented offDialog?
   hot-spots of of the shell of the first
one otherwise it is possible that the OS will give focus to
the first dialog potentially blocking the UI.
What Code Completion offers…




Which of the 56 methods
 should we override?
What You Need…
Method-level Subclassing Directives
This way, or that way?
Subclassing Patterns for ViewerSorter
How it works?
          Clustering in a nutshell




http://upload.wikimedia.org/wikipedia/en/2/29/Bernoulli-Mixture-Model.gif
“The good ones in the potty, the bad ones in…
the problem view.”
SMART BUG DETECTION –
DRIVEN BY REAL USAGES
What’s wrong with this code?
At runtime your error log shows…


An error has occurred.
See error log for more details.
org.eclipse.core.runtime.AssertionFailedException

null argument:
At runtime your error log shows…




So what have we missed?
If all of your colleagues do it – why don’t you?
How it works – a conceptual view




  That’s
“strange”
How it works – a conceptual view
Just one formula…

x = {observed method calls on a variable}
E(x) = {exact similar usages for variables of type x in the code base}
A(x) = {almost similar usages, i.e., x+1 method call}




                                         | E ( x) |
        strangeness( x) 1
                                  | E ( x) | | A( x) |
Find your bugs… during development!
Find your bugs… during development!
“Why is Google Codesearch not ‘google for code search’? ”

CODE SEARCH ENGINES – LIFT OFF!
Navigating the API jungle…




How do I get an IStatusLineManager?
When asking Google Codesearch

                          No IDE
                        integration



                       Manual query
                         creation



                        Text-based
                         retrieval



                       Ignores prior
                        knowledge
Code Example Recommender




                     Query
Code Example Recommender
Code Example Recommender
“Why is Google Codesearch not ‘google for code search’? ”

LEVERAGING USER FEEDBACK TO
IMPROVE CODE SEARCH ENGINES
Leveraging User Feedback


     ...


     ...




     ...


     ...




42
Refine the ranking based on feedback
Leveraging User Feedback



     1                              2
                 Support
     2            Vector            1
                 Machine
     3                              3




44
Stackoverflow.com – Reloaded!

WHAT CAUSED
THAT STACKTRACE?
So far we have…

Intelligent Code Completion
                                   Usage-Driven Javadocs




Code Example Recommender            Smart Bug Dectection
But what if you get this?
Debugging – the old way
Debugging – the old way
But more often we get…
How can we fix that?
Don’t stacktraces share some commonalities?
    ExceptionType Feature
    (evaluates identical exception type)              Message Similarity Feature
                                                      (counts of similar words)

org.eclipse.swt.SWTException: Invalid thread access
  at org.eclipse.swt.SWT.error(SWT.java:3884)
  at org.eclipse.swt.SWT.error(SWT.java:3799)
  at org.eclipse.swt.SWT.error(SWT.java:3770)
  at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
  at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355)
  at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317)
  at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source)
  at java.lang.Thread.run(Thread.java:619)




                                    TraceDiff Similarity Feature
                                    (counts similar stackframes per trace)
Having a central exception repository
How about stacktraces.org?
“IDE 2.0? Leveraging the wisdom of the (Eclipse) community…”

LAST.FM 4 ECLIPSE
How It Works Today


                   Framework                          If you
                                                    extend A,
                                                    you should
                                                     call B.c

  Framework                       Framework        Recommender
                       …                              Model
Instantiation 1                 Instantiation n



 extract facts about how the framework is reused




 <extends:A>                    <extends:A>
<overrides:A.b>                <overrides:A.d>
                       …         <calls:B.c>
  <calls:B.c>
       …                              …
                                                      Mining
How it Works Tomorrow


                   Framework                          If you
                                                    extend A,
                                                    you should
                                                     call B.c

  Framework                       Framework        Recommender
                       …                              Model
Instantiation 1                 Instantiation n



 extract facts about how the framework is reused




 <extends:A>                    <extends:A>
<overrides:A.b>                <overrides:A.d>
                       …         <calls:B.c>
  <calls:B.c>
       …                              …
                                                      Mining
Leveraging your IDE’s build environment
                 framework
                                     context
  project         indication
environment




                                               object
                                               usage




                selected proposals
“I’ve seen much but why do you call it IDE 2.0 ?”

WRAP UP
From IDE 1.0 to IDE 2.0
From Web 2.0 to IDE 2.0
Let’s map the Web 2.0 principles to IDE 2.0 to see how
this analogy fits:


  1. The Web as Platform…
  2. Data as “Intel inside”…
  3. Harnessing Collective Intelligence…
  4. Rich User Experiences…
  5. Lightweight Programming Models…
Milestones


           …
                               01.09.2010            01.12.2010
 21.03.2009                     Moving to            Stacktrace
v0.1 Release                   Eclipse.org          Recommender
               01.07.2010
           v0.1 Example Code           01.10.2010
                                        v0.1 Bugs              01.02.2011
             Recommender                                      v0.1 Last.FM
                                      Recommender
Resources
• Contact
   • Marcel Bruch bruch@cs.tu-darmstadt.de
   •




• Project homepage
   • http://www.stg.tu-darmstadt.de/research/core/

• Download Release “LISBON” (V.0.2.105)
   • http://www.stg.tu-darmstadt.de/research/core/download

• Source Code
   • http://eclipselabs.org/p/code-recommenders/
Credits – innumerable hours have spent…
        Peter Schroeder            Daniel Glöckner                   Johannes Lerch
                                                     Maik Görtz
     Mohsen Parisay       Jan Kassens
                                                                  Johannes Born
                          Sebastian Kasten
                                               Daniel Staesche
     Sebastian Ahlfeld                                                  David Kalnischkies
        Sebastian Wörner          Boyan Yurukov
                                                        Jan Stolzenburg
 Florian Jakob               Nico Wombacher                                      Dirk Kröhan
           Christopher Mann                     Julius Rückert
                                 Steffen Remus                     Sebastian Proksch
   Sinem Emeröz       Veronika Kostadinova
                                                 Nikolay Shindov          Tomasz Kalbarczyk
                      Michael Novotny
 Jens Krause                              Michael Kutschke                          Gary Fritz
                                                               Kristijan Madunic
     Sheip Dargutev       David Schuld
                                                                                 Sebastian Denel
Johannes Kastl                         Roman Getto Daniel Brandtner
                   Christian Kilb
     Florian Nöll                                                            Laura Altmüller
                                     Dennis Sänger      Tjark Vandommele
       Dennis Siebert
                             Markus Migenda                             Minh Hoang Nguyen
                                                  Peter Sinzig
                                 Paul Schatygin
     Jan-Michael Heller                                     Sascha Nordquist
Q&A
Summary

Intelligent Code Completion
                                        Usage-Driven Javadocs




Code Example Recommender                 Smart Bug Dectection
Affiliation
Prof. Dr. Mira Mezini
Software Technology Group
Fachbereich Informatik
Technische Universität Darmstadt

2010 06-24 karlsruher entwicklertag

  • 1.
    Eclipse Code Recommenders “IDE2.0” Collective Intelligence in Software Development Leveraging the Wisdom of the Crowds Marcel Bruch
  • 3.
    Eclipse Code Recommenders All Frameworks Code Code Eclipse Code Recommenders – do what most people do! (where appropriate) Developers Who Called “new Text()” Method Also Called setText() addListener() setLayout() setFont() 89% 53% 99% 35% What Do Developers Ultimately Override After Extending This Class? 100 % overwrote PreferencePage.createContents() 96 % overwrote PreferencePage.performOk() 5 % overwrote PreferencePage.performCancel()
  • 4.
    “Other developers frequentlybought used the following methods…” INTELLIGENT CODE COMPLETION
  • 5.
    Code Completion… What doesthe developer need, i.e., which methods should the code completion present to the user?
  • 6.
    All 164 Methodsof Text ?
  • 7.
  • 8.
    Code Completion… What doesthe developer need, i.e., which methods should the code completion present to the user?
  • 9.
    Intelligent Code Completion … or just the three missing ones?
  • 10.
  • 11.
    Why just onewhen you can have templates…
  • 12.
    How it works– in a nutshell… Framework If you extend A, you should call B.c Framework Framework Recommender … Model Instantiation 1 Instantiation n extract facts about how the framework is reused <extends:A> <extends:A> <overrides:A.b> <overrides:A.d> … <calls:B.c> <calls:B.c> … … Mining
  • 13.
    How it works– in a nutshell…
  • 14.
    How it works– in a nutshell… Observation Recommendations
  • 15.
    “What do DevelopersUltimately buy override after extending this class?” USAGE-DRIVEN JAVADOCS
  • 16.
    Some Facts AboutThe Documentation of Overridable Methods overridable 2074 overridden 623
  • 17.
    What Clients DoWith Your API… overridden 623 documented* 155 478 *: documented as overridable by using phrases like “clients may/should/must override/extend this method”
  • 18.
    What documentation wouldyou expect when subclassing a Dialog?
  • 19.
    What Javadoc givesto you… A dialog is a specialized window used for narrow-focused communication with the user. Dialogs are usually modal. Consequently, it is generally bad practice to open a dialog without a parent. A modal dialog without a parent is not prevented from disappearing behind the application's other But what are the windows, making it very confusing for the user. If there is more than one modal dialog is open the second one should be parented offDialog? hot-spots of of the shell of the first one otherwise it is possible that the OS will give focus to the first dialog potentially blocking the UI.
  • 20.
    What Code Completionoffers… Which of the 56 methods should we override?
  • 21.
  • 22.
  • 23.
    This way, orthat way? Subclassing Patterns for ViewerSorter
  • 24.
    How it works? Clustering in a nutshell http://upload.wikimedia.org/wikipedia/en/2/29/Bernoulli-Mixture-Model.gif
  • 25.
    “The good onesin the potty, the bad ones in… the problem view.” SMART BUG DETECTION – DRIVEN BY REAL USAGES
  • 26.
  • 27.
    At runtime yourerror log shows… An error has occurred. See error log for more details. org.eclipse.core.runtime.AssertionFailedException null argument:
  • 28.
    At runtime yourerror log shows… So what have we missed?
  • 29.
    If all ofyour colleagues do it – why don’t you?
  • 30.
    How it works– a conceptual view That’s “strange”
  • 31.
    How it works– a conceptual view
  • 32.
    Just one formula… x= {observed method calls on a variable} E(x) = {exact similar usages for variables of type x in the code base} A(x) = {almost similar usages, i.e., x+1 method call} | E ( x) | strangeness( x) 1 | E ( x) | | A( x) |
  • 33.
    Find your bugs…during development!
  • 34.
    Find your bugs…during development!
  • 35.
    “Why is GoogleCodesearch not ‘google for code search’? ” CODE SEARCH ENGINES – LIFT OFF!
  • 36.
    Navigating the APIjungle… How do I get an IStatusLineManager?
  • 37.
    When asking GoogleCodesearch No IDE integration Manual query creation Text-based retrieval Ignores prior knowledge
  • 38.
  • 39.
  • 40.
  • 41.
    “Why is GoogleCodesearch not ‘google for code search’? ” LEVERAGING USER FEEDBACK TO IMPROVE CODE SEARCH ENGINES
  • 42.
    Leveraging User Feedback ... ... ... ... 42
  • 43.
    Refine the rankingbased on feedback
  • 44.
    Leveraging User Feedback 1 2 Support 2 Vector 1 Machine 3 3 44
  • 45.
    Stackoverflow.com – Reloaded! WHATCAUSED THAT STACKTRACE?
  • 46.
    So far wehave… Intelligent Code Completion Usage-Driven Javadocs Code Example Recommender Smart Bug Dectection
  • 47.
    But what ifyou get this?
  • 48.
  • 49.
  • 50.
    But more oftenwe get…
  • 51.
    How can wefix that? Don’t stacktraces share some commonalities? ExceptionType Feature (evaluates identical exception type) Message Similarity Feature (counts of similar words) org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799) at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355) at org.eclipse.swt.widgets.ProgressBar.setSelection(ProgressBar.java:317) at org.eclipselabs.cr.stacktraces.demo.ThreadDemo$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:619) TraceDiff Similarity Feature (counts similar stackframes per trace)
  • 52.
    Having a centralexception repository
  • 53.
  • 54.
    “IDE 2.0? Leveragingthe wisdom of the (Eclipse) community…” LAST.FM 4 ECLIPSE
  • 55.
    How It WorksToday Framework If you extend A, you should call B.c Framework Framework Recommender … Model Instantiation 1 Instantiation n extract facts about how the framework is reused <extends:A> <extends:A> <overrides:A.b> <overrides:A.d> … <calls:B.c> <calls:B.c> … … Mining
  • 56.
    How it WorksTomorrow Framework If you extend A, you should call B.c Framework Framework Recommender … Model Instantiation 1 Instantiation n extract facts about how the framework is reused <extends:A> <extends:A> <overrides:A.b> <overrides:A.d> … <calls:B.c> <calls:B.c> … … Mining
  • 57.
    Leveraging your IDE’sbuild environment framework context project indication environment object usage selected proposals
  • 58.
    “I’ve seen muchbut why do you call it IDE 2.0 ?” WRAP UP
  • 59.
    From IDE 1.0to IDE 2.0
  • 60.
    From Web 2.0to IDE 2.0 Let’s map the Web 2.0 principles to IDE 2.0 to see how this analogy fits: 1. The Web as Platform… 2. Data as “Intel inside”… 3. Harnessing Collective Intelligence… 4. Rich User Experiences… 5. Lightweight Programming Models…
  • 61.
    Milestones … 01.09.2010 01.12.2010 21.03.2009 Moving to Stacktrace v0.1 Release Eclipse.org Recommender 01.07.2010 v0.1 Example Code 01.10.2010 v0.1 Bugs 01.02.2011 Recommender v0.1 Last.FM Recommender
  • 62.
    Resources • Contact • Marcel Bruch bruch@cs.tu-darmstadt.de • • Project homepage • http://www.stg.tu-darmstadt.de/research/core/ • Download Release “LISBON” (V.0.2.105) • http://www.stg.tu-darmstadt.de/research/core/download • Source Code • http://eclipselabs.org/p/code-recommenders/
  • 63.
    Credits – innumerablehours have spent… Peter Schroeder Daniel Glöckner Johannes Lerch Maik Görtz Mohsen Parisay Jan Kassens Johannes Born Sebastian Kasten Daniel Staesche Sebastian Ahlfeld David Kalnischkies Sebastian Wörner Boyan Yurukov Jan Stolzenburg Florian Jakob Nico Wombacher Dirk Kröhan Christopher Mann Julius Rückert Steffen Remus Sebastian Proksch Sinem Emeröz Veronika Kostadinova Nikolay Shindov Tomasz Kalbarczyk Michael Novotny Jens Krause Michael Kutschke Gary Fritz Kristijan Madunic Sheip Dargutev David Schuld Sebastian Denel Johannes Kastl Roman Getto Daniel Brandtner Christian Kilb Florian Nöll Laura Altmüller Dennis Sänger Tjark Vandommele Dennis Siebert Markus Migenda Minh Hoang Nguyen Peter Sinzig Paul Schatygin Jan-Michael Heller Sascha Nordquist
  • 64.
  • 65.
    Summary Intelligent Code Completion Usage-Driven Javadocs Code Example Recommender Smart Bug Dectection
  • 66.
    Affiliation Prof. Dr. MiraMezini Software Technology Group Fachbereich Informatik Technische Universität Darmstadt