Eclipse Code
Recommenders




IDE	
  2.0:	
  Leveraging	
  the	
  Wisdom
of	
  the	
  So:ware	
  Engineering	
  Crowds                                          dt
                                                                                    sta alk
                                                                                m
                                                                             ar chT
tw:	
  @MarcelBruch                                                    p	
  D n	
  Te
g+:	
  +Marcel	
  Bruch                                            r ou de
                                                            r 	
  G ar
                                                         se er	
  G
                                                   a	
  U lop
                                                Jav v e
                                                  De
2
Eclipse	
  Code	
  Recommenders	
  	
  	
  	
  	
  	
  
 All Frameworks        Code

Code




                                          Eclipse Code

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()


                                                                                 3
“Other	
  developers	
  frequently	
  bought	
  used	
  the	
  following	
  methods…”

INTELLIGENT	
  CODE	
  COMPLETION
Code	
  Comple8on…



@Override
protected Control createDialogArea(final Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);

      swtTextWidget = new Text(container, SWT.BORDER);
      swtTextWidget.|
      return container;
}




    What	
  does	
  the	
  developer	
  need,	
  i.e.,	
  which	
  methods	
  should	
  
              the	
  code	
  compleLon	
  present	
  to	
  the	
  user?



                                                                                           5
All	
  164	
  Methods	
  of	
  Text	
  ?
JBuTon?	
  381	
  Methods.
Code	
  Comple8on…



@Override
protected Control createDialogArea(final Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);

      swtTextWidget = new Text(container, SWT.BORDER);
      swtTextWidget.|
      return container;
}




    What	
  does	
  the	
  developer	
  need,	
  i.e.,	
  which	
  methods	
  should	
  
              the	
  code	
  compleLon	
  present	
  to	
  the	
  user?



                                                                                           8
Intelligent	
  Code	
  Comple8on




    …	
  or	
  just	
  the	
  three	
  missing	
  ones?	
  




                                                              9
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell




                                                   10
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell


  Framework




                                                   10
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell


                  Framework




  Example	
                     Example	
  
                     ...
ApplicaLon	
  1               ApplicaLon	
  n




                                                                 10
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell


                         Framework




     Example	
                                 Example	
  
                                ...
   ApplicaLon	
  1                           ApplicaLon	
  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»
        …                                         …



                                                                        10
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell


                         Framework




     Example	
                                 Example	
  
                                ...
   ApplicaLon	
  1                           ApplicaLon	
  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»
        …                                         …



                                                                        10
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell


                         Framework

                                                                          If	
  you	
  
                                                                        extend	
  A,
     Example	
                                 Example	
               you	
  should	
  
                                ...                                      call	
  B.c
   ApplicaLon	
  1                           ApplicaLon	
  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»
        …                                         …



                                                                                           10
From	
  code	
  to	
  models...


                                                       ()
                                                    ts
                                                  en ()
                                                nt Ok
                                              Co rm
                                           te fo () t() t() t()
                                         ea er t> ex on ex
                                       cr .p ni tT tF tT
                                     e. ge <i se se ge
                                   ag Pa t. t. t. t.
class Example extends Page {     :P n: ex ex ex ex ..
    Text t;                    in i    T    T    T    T .
    @Override                  1   0   1   1   0   0   …
    void createContents() {
        t = new Text();
        t.setText(..);
        ..
    }                          0   1   0   0   0   1   …
}                              …   …   …   …   …   …   …



                                                                  11
From	
  code	
  to	
  models...


                                                       ()
                                                    ts
                                                  en ()
                                                nt Ok
                                              Co rm
                                           te fo () t() t() t()
                                         ea er t> ex on ex
                                       cr .p ni tT tF tT
                                     e. ge <i se se ge
                                   ag Pa t. t. t. t.
class Example extends Page {     :P n: ex ex ex ex ..
    Text t;                    in i    T    T    T    T .
    @Override                  1   0   1   1   0   0   …
    void performOk() {
        t.getText();
        ..

    }                          0   1   0   0   0   1   …
}                              …   …   …   …   …   …   …



                                                                  12
From	
  models	
  to	
  recommenda8ons...




                                                      ()
                                                   ts
                                                 en ()
                                               nt Ok
                                             Co rm
class MyPage extends Page {               te fo () t() t() t()
                                        ea er t> ex on ex
    Text t;                           cr .p ni tT tF tT
    @Override                       e. ge <i se se ge
                                  ag Pa t. t. t. t.
    void createContents() {     :P n: ex ex ex ex ..
        t = new Text();       in i    T    T    T    T .
        t.|<^space>           1 0 1 ? ? ? …
    }
}




                                                             13
From	
  models	
  to	
  recommenda8ons...

                                    ()
                                 ts
                               en ()
                             nt Ok
                           Co rm
                        te fo () t() t() t()
                      ea er t> ex on ex
                    cr .p ni tT tF tT
                  e. ge <i se se ge
                ag Pa t. t. t. t.
              :P n: ex ex ex ex ..
            in i    T    T    T    T .
           1    0 1 1 1 0 …
           1    0 1 0 0 0 …
           1    0 1 1 0 0 …
           0    1 0 0 0 1 …
           …    … … … … … …




           1   0   1   ?   ?   ?   …


                                               14
From	
  models	
  to	
  recommenda8ons...

                                    ()
                                 ts
                               en ()
                             nt Ok
                           Co rm
                        te fo () t() t() t()
                      ea er t> ex on ex
                    cr .p ni tT tF tT
                  e. ge <i se se ge
                ag Pa t. t. t. t.
              :P n: ex ex ex ex ..
            in i    T    T    T    T .
           1    0 1 1 1 0 …
           1    0 1 0 0 0 …
           1    0 1 1 0 0 …
           0    1 0 0 0 1 …
           …    … … … … … …




           1   0   1   ⅔
                       ?   ?   ?   …


                                               14
From	
  models	
  to	
  recommenda8ons...

                                    ()
                                 ts
                               en ()
                             nt Ok
                           Co rm
                        te fo () t() t() t()
                      ea er t> ex on ex
                    cr .p ni tT tF tT
                  e. ge <i se se ge
                ag Pa t. t. t. t.
              :P n: ex ex ex ex ..
            in i    T    T    T    T .
           1    0 1 1 1 0 …
           1    0 1 0 0 0 …
           1    0 1 1 0 0 …
           0    1 0 0 0 1 …
           …    … … … … … …




           1   0   1   ⅔
                       ?   ⅓
                           ?   ?   …


                                               14
From	
  models	
  to	
  recommenda8ons...

                                    ()
                                 ts
                               en ()
                             nt Ok
                           Co rm
                        te fo () t() t() t()
                      ea er t> ex on ex
                    cr .p ni tT tF tT
                  e. ge <i se se ge
                ag Pa t. t. t. t.
              :P n: ex ex ex ex ..
            in i    T    T    T    T .
           1    0 1 1 1 0 …
           1    0 1 0 0 0 …
           1    0 1 1 0 0 …
           0    1 0 0 0 1 …
           …    … … … … … …




           1   0   1   ⅔
                       ?   ⅓
                           ?   0
                               ?   …


                                               14
“Welcome	
  to	
  the	
  forest...”

CALL-­‐CHAIN	
  COMPLETION
How	
  to	
  obtain	
  an	
  instance	
  of...


public class MyView extends ViewPart {

    public void updateMessage(final String newMessage) {

        // How do I get an instance of IStatusLineManager?

        final IStatusLineManager manager = |
        manager.setMessage(newMessage);
    }




     There is no trivial solution anymore.
  Again, what should code completion return?
What	
  we	
  need...

                                                             !"#$%&'(

                                                            5#(!"#$*"(#67
public void updateMessage(final String newMessage) {

    // How do I get an instance of
                                                             )!"#$*"(#
    final IStatusLineManager manager =
                              this
                             .getViewSite()                5#(+,-./8&'167
                             .getActionBars()
                             .getStatusLineManager();

    manager.setMessage(newMessage);                         )+,-./0&'1
}

                                                        5#(*(&(213"/#4&/&5#'67


                                                        )*(&(213"/#4&/&5#'
                                                                             17
01/1'                %1"-(
                                 2B&.#)&(&            ,#."1-
           2B&.#                 )#*"+#               01BF15"(#
                                 ,#+(&-./#            D#-7
                                 201-('"67(1'         E"5(#-#'
           201-C.7'&91-3/#B#-(   234(#-5"1-           E&A17(
                                 ?=#//                2D3
                                                      )"5F/&A
                                                      ?+'1//:&'
                                                      01-('1/
                                                      23>"(1'%&'(
                                                      2D#-7D&-&.#'
                                                      2?#'*"+#E1+&(1'
!"#$%&'(
                                                      28>&F(&6/#
                                                      2?#/#+91-
                                                      2;1'<6#-+=;"->1$
                                                      2G&*".&91-H"5(1'A
                                 2;1'<6#-+=%&'(       2;1'<"-.?#(
           2;1'<6#-+=%&'(?"(#    2@#A:"->"-.?#'*"+#   234(#-5"1-I'&+<#'
                                 2;1'<6#-+=%&.#       2!"#$,#J#'#-+#
           2!"#$?"(#             2?#/#+91-%'1*">#'    2!"#$%&'(
                                                      23>"(1',#J#'#-+#
                                 2;1'<6#-+=;"->1$     2%&'(?#'*"+#
                                                      2;1'<6#-+=
                                                      2?#/#+91-?#'*"+#
                                                      2?#'*"+#E1+&(1'
                                                      2D#-7D&-&.#'
                                 28+91-:&'5
                                                      2?(&(75E"-#D&-&.#'
                                                      28+91-
                                                      2I11/:&'D&-&.#'
Tools	
  Outline




                   19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on




                                                 19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on                 Smart	
  Bug	
  Detec8on




                                                    What	
  have	
  I	
  missed?




                                                                                   19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on                 Smart	
  Bug	
  Detec8on




                                                    What	
  have	
  I	
  missed?




 Extended	
  Documenta8on




                                                                                   19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on                    Smart	
  Bug	
  Detec8on




                                                          What	
  have	
  I	
  missed?




 Extended	
  Documenta8on                        Code	
  Example	
  Recommender




                                                  How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                    19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on                                              Smart	
  Bug	
  Detec8on




                                                                                    What	
  have	
  I	
  missed?


                                   Stacktrace	
  Search	
  Engine


 Extended	
  Documenta8on                                                  Code	
  Example	
  Recommender

                                   What	
  caused	
  that	
  stacktrace?




                                                                            How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                                              19
Tools	
  Outline

Intelligent	
  Code	
  Comple8on                                              Smart	
  Bug	
  Detec8on




                                                                                    What	
  have	
  I	
  missed?


                                   Stacktrace	
  Search	
  Engine


 Extended	
  Documenta8on                                                  Code	
  Example	
  Recommender

                                   What	
  caused	
  that	
  stacktrace?




                                                                            How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                                              19
“The	
  good	
  ones	
  in	
  the	
  crock,	
  the	
  bad	
  ones	
  in…	
  the	
  problem	
  view.”

SMART	
  BUG	
  DETECTION	
  –	
  
DRIVEN	
  BY	
  REAL	
  USAGES
What’s	
  wrong	
  with	
  this	
  code?




          “Hello!”




                     “id”




                                           21
At	
  run8me	
  you	
  get…




                              22
...and	
  a	
  lengthy	
  stacktrace
org.eclipse.core.run8me.Asser8onFailedExcep8on:	
  null	
  argument:
 at	
  org.eclipse.core.run8me.Assert.isNotNull(Assert.java:85)
 at	
  org.eclipse.core.run8me.Assert.isNotNull(Assert.java:73)
 at	
  org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174)
 at	
  org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:734)
 at	
  org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1162)
 at	
  org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1221)
 at	
  org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1218)
 at	
  org.eclipse.jface.wizard.WizardDialog$6.run(WizardDialog.java:1207)
 at	
  org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
 at	
  org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1205)
 at	
  org.eclipse.ui.internal.dialogs.ImportExportPage.treeDoubleClicked(ImportExportPage.java)
 at	
  org.eclipse.ui.internal.dialogs.ImportPage$2.doubleClick(ImportPage.java:72)
 at	
  org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824)
 at	
  org.eclipse.core.run8me.SafeRunner.run(SafeRunner.java:42)
 at	
  org.eclipse.ui.internal.JFaceU8l$1.run(JFaceU8l.java:49)
 at	
  org.eclipse.jface.u8l.SafeRunnable.run(SafeRunnable.java:175)
 at	
  org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822)
 at	
  org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java)
 at	
  org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java)
                                               ...                                                 23
So what have we missed?
                          24
If	
  all	
  of	
  your	
  colleagues	
  do	
  it	
  –	
  why	
  don’t	
  you?




                                                                                 25
If	
  all	
  of	
  your	
  colleagues	
  do	
  it	
  –	
  why	
  don’t	
  you?




                                                                                 25
How	
  to	
  detect	
  such	
  wrong	
  uses?




                                                26
How	
  to	
  detect	
  such	
  wrong	
  uses?




                                                26
How	
  to	
  detect	
  such	
  wrong	
  uses?




                                                26
How	
  to	
  detect	
  such	
  wrong	
  uses?




                                                26
How	
  to	
  detect	
  such	
  wrong	
  uses?




That’s	
  “strange”




                                                                      26
How	
  to	
  detect	
  such	
  wrong	
  uses?




                                                27
Just	
  one	
  formula…




                   0             .5         .9    1



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}
                                                                         28
Missing	
  Calls	
  Detector	
  in	
  Eclipse




                                                29
Applied	
  on	
  Eclipse	
  3.5...




                                     30
“Developers	
  who	
  bought	
  overwrote	
  this	
  method	
  typically	
  also	
  overwrote...”

USAGE-­‐DRIVEN	
  JAVADOC
In	
  good	
  documenta8on	
  we	
  trust...



/**
  * Rollsback the transaction if any and clears different lists to
  * start with an empty resource again.
  * Note that the super.doUnload is not called because that clears
  * the list resulting in all kinds of undesirable inverseremoves.
  */
@Override
protected void doUnload() {
     super.doUnload();
}




                                                                     32
In	
  good	
  documenta8on	
  we	
  trust...



/**
  * Rollsback the transaction if any and clears different lists to
  * start with an empty resource again.
  * Note that the super.doUnload is not called because that clears
  * the list resulting in all kinds of undesirable inverseremoves.
  */
@Override
protected void doUnload() {
     super.doUnload();
}




                                                                     32
In	
  good	
  documenta8on	
  we	
  trust...



/**
  * Rollsback the transaction if any and clears different lists to
  * start with an empty resource again.
  * Note that the super.doUnload is not called because that clears
  * the list resulting in all kinds of undesirable inverseremoves.
  */
@Override
protected void doUnload() {
     super.doUnload();
}




                               No?	
  Are	
  you	
  sure?



                                                                     32
In	
  good documenta8on	
  we	
  trust...
         good	
  



/**
  * Rollsback the transaction if any and clears different lists to
  * start with an empty resource again.
  * Note that the super.doUnload is not called because that clears
  * the list resulting in all kinds of undesirable inverseremoves.
  */
@Override
protected void doUnload() {
     super.doUnload();
}




                               No?	
  Are	
  you	
  sure?



                                                                     32
Genera8ng	
  high-­‐quality	
  API	
  documenta8on




                                                     33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          33
Genera8ng	
  high-­‐quality API	
  documenta8on
             high-­‐quality	
  


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          34
Genera8ng	
  high-­‐quality	
  API	
  documenta8on


  /**
   * The number of questions.
   */
  private int numberOfQuestions;


  /**
    * Sets the number of questions.
    *
    * @param numberOfQuestions the number of questions
    * @throws IllegalArgumentException the illegal argument exception
    */
  public void setNumberOfQuestions(int numberOfQuestions)
                                  throws IllegalArgumentException {
       if (numberOfQuestions < 0) {
           throw new IllegalArgumentException("numberOfQuestions < 0");
       }
       this.numberOfQuestions = numberOfQuestions;
  }




                                                                          34
What	
  people	
  say	
  about	
  JAutodoc...




                                                35
What	
  people	
  say	
  about	
  JAutodoc...

User: Anonymous              Rating: 9   2009-08-02 11:32:37

Wow exactly what I needed!




                                                               35
What	
  people	
  say	
  about	
  JAutodoc...

User: Anonymous                   Rating: 9   2009-08-02 11:32:37

Wow exactly what I needed!


User: Anonymous                   Rating: 9   2009-02-13 19:58:32

Thank you... this plugin rocks!




                                                                    35
What	
  people	
  say	
  about	
  JAutodoc...

User: Anonymous                   Rating: 9   2009-08-02 11:32:37

Wow exactly what I needed!


User: Anonymous                   Rating: 9   2009-02-13 19:58:32

Thank you... this plugin rocks!


User: Anonymous                   Rating: 9   2009-02-13 19:58:32

Works perfectly. Smarter than I expected!




                                                                    35
What	
  people	
  say	
  about	
  JAutodoc...

User: Anonymous                   Rating: 9   2009-08-02 11:32:37

Wow exactly what I needed!


User: Anonymous                   Rating: 9   2009-02-13 19:58:32

Thank you... this plugin rocks!


User: Anonymous                   Rating: 9   2009-02-13 19:58:32

Works perfectly. Smarter than I expected!




           WTH?	
  What	
  did	
  you	
  expect?!
                                                                    35
How	
  Recommenders	
  is	
  coming	
  to	
  rescue...




                                                         36
Some	
  facts	
  about	
  the
              documenta8on	
  of	
  overridable	
  methods




Overridable                                           2.074


Overridden              623


              0               700        1400            2100



                                                                37
What	
  clients	
  do	
  with	
  your	
  API...




        Overridden                                                                                               623


   Documented *                             155


                         0                                              325                                             650




*	
  documented	
  as	
  overridable	
  by	
  using	
  phrases	
  like	
  “clients	
  may/should/must	
  override/extend	
  this	
  method” 38
What	
  clients	
  do	
  with	
  your	
  API...




        Overridden                                                                                               623


   Documented *                             155                                                                  478

                         0                                              325                                             650




*	
  documented	
  as	
  overridable	
  by	
  using	
  phrases	
  like	
  “clients	
  may/should/must	
  override/extend	
  this	
  method” 38
What	
  documenta8on	
  would	
  you	
  expect	
  when	
  
             subclassing	
  Dialog?



        package org.eclipse.recommenders.examples.demo;

        import org.eclipse.jface.dialogs.Dialog;
        import org.eclipse.jface.window.IShellProvider;

        public class MyDialog extends Dialog {

            protected MyDialog(final IShellProvider parentShell) {
                super(parentShell);
            }
        }




                                                                     39
What	
  Javadoc	
  gives	
  you...




                                     40
What	
  Javadoc	
  gives	
  you...



A	
  dialog	
  is	
  a	
  specialized	
  window	
  used	
  for	
  narrow-­‐focused	
  
communica8on	
  with	
  the	
  user.	
  




                                                                                         40
What	
  Javadoc	
  gives	
  you...



A	
  dialog	
  is	
  a	
  specialized	
  window	
  used	
  for	
  narrow-­‐focused	
  
communica8on	
  with	
  the	
  user.	
  

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

If	
  there	
  is	
  more	
  than	
  one	
  modal	
  dialog	
  is	
  open	
  the	
  second	
  
one	
  should	
  be	
  parented	
  off	
  of	
  the	
  shell	
  of	
  the	
  first	
  one	
  
otherwise	
  it	
  is	
  possible	
  that	
  the	
  OS	
  will	
  cus	
  to	
  the	
  first	
  
dialog	
  poten8ally	
  blocking	
  the	
  UI.	
  



                                                                                                 40
What	
  Javadoc	
  gives	
  you...



 A	
  dialog	
  is	
  a	
  specialized	
  window	
  used	
  for	
  narrow-­‐focused	
  
 communica8on	
  with	
  the	
  user.	
  

 Dialogs	
  are	
  usually	
  modal.	
  Consequently,	
  it	
  is	
  generally	
  
 bad	
  prac8ce	
  to	
  open	
  a	
  dialog	
  without	
  a	
  parent.	
  A	
  modal	
  
 dialog	
  without	
  a	
  parent	
  is	
  not	
  prevented	
  from	
  

  But what are the
 disappearing	
  behind	
  the	
  applica8on's	
  other	
  windows,	
  
 making	
  it	
  very	
  confusing	
  for	
  the	
  user.	
  


hot-spots of Dialog?
 If	
  there	
  is	
  more	
  than	
  one	
  modal	
  dialog	
  is	
  open	
  the	
  second	
  
 one	
  should	
  be	
  parented	
  off	
  of	
  the	
  shell	
  of	
  the	
  first	
  one	
  
 otherwise	
  it	
  is	
  possible	
  that	
  the	
  OS	
  will	
  cus	
  to	
  the	
  first	
  
 dialog	
  poten8ally	
  blocking	
  the	
  UI.	
  



                                                                                                  40
What	
  code	
  comple8on	
  offers...




                                        41
What	
  code	
  comple8on	
  offers...




Which of the 56 methods
  should we override?

                                          41
Recommending	
  method	
  overrides...

public class MyDialog extends Dialog {




                                              42
Recommending	
  Self-­‐Calls

public class MyDialog extends Dialog {

   @Override
   protected Control createDialogArea(Composite parent) {




                                                            43
Mining	
  for	
  Subclassing	
  parerns

public class MyViewerComparator extends ViewerComparator {




                                                             44
Mining	
  example	
  code	
  snippets

public class MyDialog extends Dialog {

   @Override
   protected Control createDialogArea(Composite parent) {




                                                            45
Scarered	
  Resources




                        46
Scarered	
  Resources




                        46
Scarered	
  Resources




                        46
Extended	
  Documenta8on	
  Plasorm
                      + Machine Learning




                                           47
Extended	
  Documenta8on




                           48
How	
  it	
  works	
  -­‐	
  in	
  a	
  nutshell




                                                   49
“Why	
  is	
  Google	
  Codesearch	
  not	
  ‘google	
  for	
  code	
  search’?	
  ”

CODE-­‐SEARCH	
  ENGINES	
  LIFT	
  OFF
How	
  many	
  request	
  per	
  minutes	
  do
   code	
  search	
  engines	
  have?




                                                 51
20
Number	
  for	
  koders.com	
  in	
  2009	
  according	
  to	
  	
  “Analyzing	
  and	
  mining	
  a	
  code	
  search	
  engine	
  usage	
  log”
                                                                            hrp://dx.doi.org/10.1007/s10664-­‐010-­‐9144-­‐6 52
Naviga8ng	
  the	
  API	
  jungle…


private CompilationUnit createCompilationUnit(String source) {

    // how can I create and configure an ASTParser?
    ASTParser parser = null;
    parser.setSource(source.toCharArray());

    // ASTParser --> CompilationUnit: how?
    CompilationUnit cu = null;
    return cu;
}




                                                                 53
Naviga8ng	
  the	
  API	
  jungle…


  private CompilationUnit createCompilationUnit(String source) {

      // how can I create and configure an ASTParser?
      ASTParser parser = null;
      parser.setSource(source.toCharArray());

      // ASTParser --> CompilationUnit: how?
      CompilationUnit cu = null;
      return cu;
  }




                      How	
  to	
  solve
String	
  -­‐>	
  ASTParser	
  -­‐>	
  CompilaLonUnit?

                                                                   53
When	
  asking	
  Google	
  code	
  search...




                                                54
When	
  asking	
  Google	
  code	
  search...




                                                54
When	
  asking	
  Google	
  code	
  search...




                                                54
When	
  asking	
  Google	
  code	
  search...




                                                54
Why?




       55
Why?



       Text-based
        retrieval!




                     55
Why?



          Text-based
           retrieval!


       Inexpressive query
           language!




                            55
Why?



          Text-based
           retrieval!


       Inexpressive query
           language!


         Ignores prior
          knowledge!




                            55
Why?



          Text-based
           retrieval!


       Inexpressive query
           language!


         Ignores prior
          knowledge!


            License
            Issues!




                            55
Example	
  code	
  search	
  engine



public class MyJavaEditor extends EditorPart {

   private CompilationUnit createCompilationUnit(String source) {

        // how can I create and configure an ASTParser?
        ASTParser parser = null;
        parser.setSource(source.toCharArray());

        // ASTParser --> CompilationUnit: how?
        CompilationUnit cu = null;
        return cu;
    }




                                                                    56
Example	
  code	
  search	
  engine



public class MyJavaEditor extends EditorPart {

   private CompilationUnit createCompilationUnit(String source) {

        // how can I create and configure an ASTParser?
        ASTParser parser = null;
        parser.setSource(source.toCharArray());
                                                            Query
        // ASTParser --> CompilationUnit: how?
        CompilationUnit cu = null;
        return cu;
    }




                                                                    56
“Why	
  is	
  Google	
  Codesearch	
  not	
  ‘google	
  for	
  code	
  search’?	
  ”

LEVERAGING	
  USER	
  FEEDBACK	
  TO
IMPROVE	
  CODE	
  SEARCH	
  ENGINES
Leveraging	
  user	
  feedback




                                 58
Leveraging	
  user	
  feedback




                                 58
Refine	
  the	
  ranking	
  based	
  on	
  feedback




                                                     59
Refine	
  the	
  ranking	
  based	
  on	
  feedback




                                                     59
Learning	
  how	
  to	
  rank




                                60
Ranking	
  the	
  examples




                             61
Ranking	
  the	
  examples




document




                                        61
Ranking	
  the	
  examples




document
      query



                                        61
Ranking	
  the	
  examples




document
      query                       feature-­‐score	
  i
                                       [0..1]



                                                         61
Ranking	
  the	
  examples




document
      query             weight	
     feature-­‐score	
  i
                      (-­‐∞..+∞)          [0..1]



                                                            61
Upda8ng	
  the	
  feature	
  weights...




                                          62
Upda8ng	
  the	
  feature	
  weights...




                                          62
Upda8ng	
  the	
  feature	
  weights...




10.000	
  ∗



                                                        62
Benefits	
  of	
  automated	
  tweaking
#	
  kendall’s	
  ι




                                          #	
  queries



                      baseline
                      click-­‐through

                                                                   63
Interac8ons	
  diagram
           Client                                                          Server

                    1


    Developer           «triggers»

2         Search Invocation
                                                                3    Code Snippet Ranking
            Incomplete
           Source Code                   Query                      Ranking         Search
                                                                    Function        Index


4     Code Snippet Presentation                      Code                      «updates»
                                                     Examples
                                                                5    Feedback Processing
       Code                   Code
    Summarization          Highlighter
                                                                       Weights Learning
                                            Clickthrough
                                            Cli kth    h                  Function
                                            data
                                                                                             64
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                                              65
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories




                                                              65
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories




                                                              65
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories




                                                              65
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories




                                                              65
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories


 Filesystem	
  



                                                              65
“People	
  that	
  bought	
  had	
  this	
  NullPointerExcepKon,	
  made	
  this	
  mistake:...”

WHAT	
  CAUSED	
  THAT	
  STACKTRACE?
So	
  far	
  we	
  have…




                           67
So	
  far	
  we	
  have…

Intelligent	
  Code	
  Comple8on




                                                      67
So	
  far	
  we	
  have…

Intelligent	
  Code	
  Comple8on                      Extended	
  Documenta8on




                                                                                 67
So	
  far	
  we	
  have…

Intelligent	
  Code	
  Comple8on                      Extended	
  Documenta8on




                                                      Code	
  Example	
  Recommender




                                                       How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                         67
So	
  far	
  we	
  have…

Intelligent	
  Code	
  Comple8on                                Extended	
  Documenta8on




   Smart	
  Bug	
  Detec8on                                     Code	
  Example	
  Recommender




      What	
  have	
  I	
  missed?                               How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                                   67
But	
  what	
  if	
  you	
  get	
  this?




                                           68
Debugging	
  –	
  the	
  old	
  way




                                      69
Debugging	
  –	
  the	
  old	
  way




                                      69
Debugging	
  –	
  the	
  old	
  way




                                      70
But	
  more	
  ozen	
  we	
  get…




                                    71
How	
  can	
  we	
  fix	
  that?	
  
Don’t	
  stacktraces	
  share	
  some	
  commonali8es?




                                                         72
How	
  can	
  we	
  fix	
  that?	
  
Don’t	
  stacktraces	
  share	
  some	
  commonali8es?



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)




                                                                              72
How	
  can	
  we	
  fix	
  that?	
  
Don’t	
  stacktraces	
  share	
  some	
  commonali8es?



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)




                                                                              72
How	
  can	
  we	
  fix	
  that?	
  
Don’t	
  stacktraces	
  share	
  some	
  commonali8es?

   Excep8onType	
  Feature
   (evaluates	
  iden8cal	
  excep8on	
  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)

                                                                                                              72
How	
  about	
  stacktraces.org?




                                   73
Applica8on	
  scenarios	
  for	
  your	
  	
  company

                                             Open	
  Source
                                             Repositories




                                              Company
                                             Repositories




                                                              74
“IDE	
  2.0?	
  Leveraging	
  the	
  wisdom	
  of	
  the	
  (Eclipse)	
  community…”

ECLIPSE	
  CODE	
  RECOMMENDERS
A	
  developer’s	
  day...
                               Switching
                              Applications
                                                                           Edit Code
           Searching Code




                                                                                                     Testing
  Navigate
Dependencies




Reading API Doc
                                                                                   Comprehend Task




                                                                                        Handling
           Comprehending                                                              Interruptions
               Code




                             Source:	
  Eclipse	
  Mylyn	
  Developer	
  Techtalk	
  2011,	
  IEEE	
  TSE,	
  Vol.	
  32,	
  No.	
  12,	
  2006 76
From	
  IDE	
  1.0	
  to	
  IDE	
  2.0




                                         77
From	
  IDE	
  1.0	
  to	
  IDE	
  2.0




                                         77
Where	
  does	
  IDE	
  2.0	
  improve	
  the	
  process?



      Edit Code
                                            Testing




                                             Comprehend Task



                                             Handling
                                           Interruptions



                   …
                                                                78
Build	
  directly	
  from	
  version	
  control


                                         P2




                                                  79
Leveraging	
  your	
  IDE’s	
  build	
  environment




                                                      80
Leveraging	
  your	
  IDE’s	
  build	
  environment




  project
environment




                                                            80
Leveraging	
  your	
  IDE’s	
  build	
  environment
                     context




  project
environment




                                                            80
Leveraging	
  your	
  IDE’s	
  build	
  environment
                     context
                                                      object
                                                      usage



  project
environment




                                                               80
Leveraging	
  your	
  IDE’s	
  build	
  environment
                     context
                                                      object
                                                      usage



  project                                             selected
environment                                          proposals




                                                               80
Leveraging	
  your	
  IDE’s	
  build	
  environment
                     context
                                                      object
                                                      usage



  project                                             selected
environment                                          proposals

                                                        click
                                                      feedback




                                                               80
Leveraging	
  your	
  IDE’s	
  build	
  environment
                     context
                                                      object
                                                      usage



  project                                             selected
environment                                          proposals

                                                        click
                                                      feedback




                                  Stacktraces                  80
Crowd-­‐sourcing




                   81
“Yours	
  is	
  ours	
  and	
  mine	
  is	
  mine...”

BUT	
  HOW	
  ABOUT	
  PRIVACY?
Usage	
  data	
  sharing	
  example
import com.mycompany.*;
import org.eclipse.*;

public class MyCompanyDialog extends Dialog implements ICompanyService {

    MyCompanyController controller = new MyCompanyController();

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        Button sync = new Button(container, SWT.CHECK);
        sync.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (sync.getSelection()) {
                    controller.synchronize();
                    // lot of more things done with controller
                }
            }
        });
        return container;
    }

    @Override
    public void myCompanyServiceMethod() {
        controller.setup();
    }                                                                       83
}
Usage	
  data	
  sharing	
  example
import com.mycompany.*;
import org.eclipse.*;

public class MyCompanyDialog extends Dialog implements ICompanyService {

    MyCompanyController controller = new MyCompanyController();

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        Button sync = new Button(container, SWT.CHECK);
        sync.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (sync.getSelection()) {
                    controller.synchronize();
                    // lot of more things done with controller
                }
            }
        });
        return container;
    }

    @Override
    public void myCompanyServiceMethod() {
        controller.setup();
    }                                                                       83
}
Informa8on	
  cleared	
  by	
  privacy	
  se{ngs
import com.mycompany.*;
import org.eclipse.*;

public class MyCompanyDialog extends Dialog implements ICompanyService {

    MyCompanyController controller = new MyCompanyController();

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        Button sync = new Button(container, SWT.CHECK);
        sync.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (sync.getSelection()) {
                    controller.synchronize();
                    // lot of more things done with controller
                }
            }
        });
        return container;
    }

    @Override
    public void myCompanyServiceMethod() {
        controller.setup();
    }                                                                       84
}
Effec8ve	
  usage	
  data	
  shared
import com.mycompany.*;
import org.eclipse.*;

public class MyCompanyDialog extends Dialog implements ICompanyService {

    MyCompanyController controller = new MyCompanyController();

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        Button sync = new Button(container, SWT.CHECK);
        sync.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (sync.getSelection()) {
                    controller.synchronize();

                }
            }
        });
        return container;
    }

    @Override
    public void myCompanyServiceMethod() {
        controller.setup();
    }                                                                       85
}
Effec8ve	
  usage	
  data	
  shared
import com.mycompany.*;
import org.eclipse.*;

public class MyCompanyDialog extends Dialog implements ICompanyService {

    MyCompanyController controller = new MyCompanyController();

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite container = (Composite) super.createDialogArea(parent);
        Button sync = new Button(container, SWT.CHECK);
        sync.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                if (sync.getSelection()) {
                    controller.synchronize();

                }
        Only	
  the	
  informaLon	
  how	
  you	
  
        });
            }


           used	
  Eclipse	
  is	
  shared.
        return container;
    }

    @Override
    public void myCompanyServiceMethod() {
        controller.setup();
    }                                                                       85
}
“Support	
  your	
  own	
  framework.	
  Live	
  walk-­‐through...”

RECOMMENDERS	
  FOR	
  ANDROID
87
Summary

Intelligent	
  Code	
  Comple8on                                                   Usage-­‐Driven	
  Javadocs




                                      Stacktrace	
  Search	
  Engine


   Smart	
  Bug	
  Detec8on                                               Code	
  Example	
  Recommender


                                      What	
  caused	
  that	
  stacktrace?



       What	
  have	
  I	
  missed?                                           How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                                                88
Contributors	
  so	
  far…
Jan	
   Kassens,	
   	
   Peter	
  Schroeder,	
  Daniel	
  Glöckner,	
  Maik	
   Görtz,	
  Johannes	
   Lerch,	
  Johannes	
  Born,	
  
Mohsen	
  Parisay,	
  Andreas	
  Sewe,	
  SebasLan	
  Ahlfeld,	
  SebasLan	
  Kasten,	
  Daniel	
  Staesche,	
  David	
  
Kalnischkies,	
   SebasLan	
   Wörner,	
   Boyan	
   Yurukov,	
   Jan	
   Stolzenburg,	
   Nico	
   Wombacher,	
   Dirk	
  
Kröhan,	
   Florianrian	
   Jakob,	
   Julius	
   Rückert,	
   Steffen	
   Remus,	
   Christopher	
   Mann,	
   Stefan	
   Henss,	
  
Andreas	
   Kaluza,	
   Nikolay	
   Shindov,	
   Michael	
   Novotny,	
   KrisLn	
   Arand,	
   Sinem	
   Emeröz,	
   Michael	
  
Kutschke,	
   SebasLan	
   Proksch,	
   Tomasz	
   Kalbarczyk,	
   Marko	
   MarLn,	
   Sheip	
   Dargutev,	
   David	
  
Schuld,	
   Jens	
   Krause,	
   KrisLjan	
   Madunic,	
   Daniel	
   Brandtner,	
   Roman	
   GeTo,	
   ChrisLan	
   Kilb,	
  
Johannes	
   Kastl,	
   Dennis	
   Sänger,	
   Annie	
   Liu,	
   Markus	
   Migenda,	
   Tjark	
   Vandommele,	
   SebasLan	
  
Denel,	
  Florian	
  Nöll,	
   Gary	
  Fritz,	
  Dennis	
  Siebert,	
  Peter	
  Sinzig,	
  Laura	
  Altmüller,	
  Paul	
  Schatygin,	
  
Jan-­‐Michael	
  Heller,	
  Minh	
  Hoang	
  Nguyen,	
  Sascha	
  Nordquist,	
  Paul	
  Emmanuel	
  Faidherbe,	
  ...




                                                                                                                                       89
Q	
  &	
  A




              90
Q	
  &	
  A

Intelligent	
  Code	
  Comple8on                                                   Usage-­‐Driven	
  Javadocs




                                      Stacktrace	
  Search	
  Engine


   Smart	
  Bug	
  Detec8on                                               Code	
  Example	
  Recommender


                                      What	
  caused	
  that	
  stacktrace?



       What	
  have	
  I	
  missed?                                           How	
  do	
  I	
  get	
  an	
  instance	
  of…?

                                                                                                                                91
It’s	
  there.




hrp://eclipse.org/recommenders/
            Follow	
  me	
  on	
  twirer:	
  @MarcelBruch
                              google+:	
  +Marcel	
  Bruch   92

Eclipse Code Recommenders @ cross-event Deutsche Telekom Developer Garden TechTalk and Java User Group Darmstadt

  • 1.
    Eclipse Code Recommenders IDE  2.0:  Leveraging  the  Wisdom of  the  So:ware  Engineering  Crowds dt sta alk m ar chT tw:  @MarcelBruch p  D n  Te g+:  +Marcel  Bruch r ou de r  G ar se er  G a  U lop Jav v e De
  • 2.
  • 3.
    Eclipse  Code  Recommenders             All Frameworks Code Code Eclipse Code 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() 3
  • 4.
    “Other  developers  frequently  bought  used  the  following  methods…” INTELLIGENT  CODE  COMPLETION
  • 5.
    Code  Comple8on… @Override protected ControlcreateDialogArea(final Composite parent) { Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container; } What  does  the  developer  need,  i.e.,  which  methods  should   the  code  compleLon  present  to  the  user? 5
  • 7.
    All  164  Methods  of  Text  ?
  • 8.
  • 9.
    Code  Comple8on… @Override protected ControlcreateDialogArea(final Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); swtTextWidget = new Text(container, SWT.BORDER); swtTextWidget.| return container; } What  does  the  developer  need,  i.e.,  which  methods  should   the  code  compleLon  present  to  the  user? 8
  • 10.
    Intelligent  Code  Comple8on …  or  just  the  three  missing  ones?   9
  • 11.
    How  it  works  -­‐  in  a  nutshell 10
  • 12.
    How  it  works  -­‐  in  a  nutshell Framework 10
  • 13.
    How  it  works  -­‐  in  a  nutshell Framework Example   Example   ... ApplicaLon  1 ApplicaLon  n 10
  • 14.
    How  it  works  -­‐  in  a  nutshell Framework Example   Example   ... ApplicaLon  1 ApplicaLon  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» … … 10
  • 15.
    How  it  works  -­‐  in  a  nutshell Framework Example   Example   ... ApplicaLon  1 ApplicaLon  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» … … 10
  • 16.
    How  it  works  -­‐  in  a  nutshell Framework If  you   extend  A, Example   Example   you  should   ... call  B.c ApplicaLon  1 ApplicaLon  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» … … 10
  • 17.
    From  code  to  models... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. class Example extends Page { :P n: ex ex ex ex .. Text t; in i T T T T . @Override 1 0 1 1 0 0 … void createContents() { t = new Text(); t.setText(..); .. } 0 1 0 0 0 1 … } … … … … … … … 11
  • 18.
    From  code  to  models... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. class Example extends Page { :P n: ex ex ex ex .. Text t; in i T T T T . @Override 1 0 1 1 0 0 … void performOk() { t.getText(); .. } 0 1 0 0 0 1 … } … … … … … … … 12
  • 19.
    From  models  to  recommenda8ons... () ts en () nt Ok Co rm class MyPage extends Page { te fo () t() t() t() ea er t> ex on ex Text t; cr .p ni tT tF tT @Override e. ge <i se se ge ag Pa t. t. t. t. void createContents() { :P n: ex ex ex ex .. t = new Text(); in i T T T T . t.|<^space> 1 0 1 ? ? ? … } } 13
  • 20.
    From  models  to  recommenda8ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ? ? ? … 14
  • 21.
    From  models  to  recommenda8ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ? ? … 14
  • 22.
    From  models  to  recommenda8ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ⅓ ? ? … 14
  • 23.
    From  models  to  recommenda8ons... () ts en () nt Ok Co rm te fo () t() t() t() ea er t> ex on ex cr .p ni tT tF tT e. ge <i se se ge ag Pa t. t. t. t. :P n: ex ex ex ex .. in i T T T T . 1 0 1 1 1 0 … 1 0 1 0 0 0 … 1 0 1 1 0 0 … 0 1 0 0 0 1 … … … … … … … … 1 0 1 ⅔ ? ⅓ ? 0 ? … 14
  • 24.
    “Welcome  to  the  forest...” CALL-­‐CHAIN  COMPLETION
  • 25.
    How  to  obtain  an  instance  of... public class MyView extends ViewPart { public void updateMessage(final String newMessage) { // How do I get an instance of IStatusLineManager? final IStatusLineManager manager = | manager.setMessage(newMessage); } There is no trivial solution anymore. Again, what should code completion return?
  • 26.
    What  we  need... !"#$%&'( 5#(!"#$*"(#67 public void updateMessage(final String newMessage) { // How do I get an instance of )!"#$*"(# final IStatusLineManager manager = this .getViewSite() 5#(+,-./8&'167 .getActionBars() .getStatusLineManager(); manager.setMessage(newMessage); )+,-./0&'1 } 5#(*(&(213"/#4&/&5#'67 )*(&(213"/#4&/&5#' 17
  • 27.
    01/1' %1"-( 2B&.#)&(& ,#."1- 2B&.# )#*"+# 01BF15"(# ,#+(&-./# D#-7 201-('"67(1' E"5(#-#' 201-C.7'&91-3/#B#-( 234(#-5"1- E&A17( ?=#// 2D3 )"5F/&A ?+'1//:&' 01-('1/ 23>"(1'%&'( 2D#-7D&-&.#' 2?#'*"+#E1+&(1' !"#$%&'( 28>&F(&6/# 2?#/#+91- 2;1'<6#-+=;"->1$ 2G&*".&91-H"5(1'A 2;1'<6#-+=%&'( 2;1'<"-.?#( 2;1'<6#-+=%&'(?"(# 2@#A:"->"-.?#'*"+# 234(#-5"1-I'&+<#' 2;1'<6#-+=%&.# 2!"#$,#J#'#-+# 2!"#$?"(# 2?#/#+91-%'1*">#' 2!"#$%&'( 23>"(1',#J#'#-+# 2;1'<6#-+=;"->1$ 2%&'(?#'*"+# 2;1'<6#-+= 2?#/#+91-?#'*"+# 2?#'*"+#E1+&(1' 2D#-7D&-&.#' 28+91-:&'5 2?(&(75E"-#D&-&.#' 28+91- 2I11/:&'D&-&.#'
  • 28.
  • 29.
  • 30.
    Tools  Outline Intelligent  Code  Comple8on Smart  Bug  Detec8on What  have  I  missed? 19
  • 31.
    Tools  Outline Intelligent  Code  Comple8on Smart  Bug  Detec8on What  have  I  missed? Extended  Documenta8on 19
  • 32.
    Tools  Outline Intelligent  Code  Comple8on Smart  Bug  Detec8on What  have  I  missed? Extended  Documenta8on Code  Example  Recommender How  do  I  get  an  instance  of…? 19
  • 33.
    Tools  Outline Intelligent  Code  Comple8on Smart  Bug  Detec8on What  have  I  missed? Stacktrace  Search  Engine Extended  Documenta8on Code  Example  Recommender What  caused  that  stacktrace? How  do  I  get  an  instance  of…? 19
  • 34.
    Tools  Outline Intelligent  Code  Comple8on Smart  Bug  Detec8on What  have  I  missed? Stacktrace  Search  Engine Extended  Documenta8on Code  Example  Recommender What  caused  that  stacktrace? How  do  I  get  an  instance  of…? 19
  • 35.
    “The  good  ones  in  the  crock,  the  bad  ones  in…  the  problem  view.” SMART  BUG  DETECTION  –   DRIVEN  BY  REAL  USAGES
  • 36.
    What’s  wrong  with  this  code? “Hello!” “id” 21
  • 37.
    At  run8me  you  get… 22
  • 38.
    ...and  a  lengthy  stacktrace org.eclipse.core.run8me.Asser8onFailedExcep8on:  null  argument: at  org.eclipse.core.run8me.Assert.isNotNull(Assert.java:85) at  org.eclipse.core.run8me.Assert.isNotNull(Assert.java:73) at  org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) at  org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:734) at  org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1162) at  org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1221) at  org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1218) at  org.eclipse.jface.wizard.WizardDialog$6.run(WizardDialog.java:1207) at  org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at  org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1205) at  org.eclipse.ui.internal.dialogs.ImportExportPage.treeDoubleClicked(ImportExportPage.java) at  org.eclipse.ui.internal.dialogs.ImportPage$2.doubleClick(ImportPage.java:72) at  org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824) at  org.eclipse.core.run8me.SafeRunner.run(SafeRunner.java:42) at  org.eclipse.ui.internal.JFaceU8l$1.run(JFaceU8l.java:49) at  org.eclipse.jface.u8l.SafeRunnable.run(SafeRunnable.java:175) at  org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822) at  org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java) at  org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java) ... 23
  • 39.
    So what havewe missed? 24
  • 40.
    If  all  of  your  colleagues  do  it  –  why  don’t  you? 25
  • 41.
    If  all  of  your  colleagues  do  it  –  why  don’t  you? 25
  • 42.
    How  to  detect  such  wrong  uses? 26
  • 43.
    How  to  detect  such  wrong  uses? 26
  • 44.
    How  to  detect  such  wrong  uses? 26
  • 45.
    How  to  detect  such  wrong  uses? 26
  • 46.
    How  to  detect  such  wrong  uses? That’s  “strange” 26
  • 47.
    How  to  detect  such  wrong  uses? 27
  • 48.
    Just  one  formula… 0 .5 .9 1 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} 28
  • 49.
    Missing  Calls  Detector  in  Eclipse 29
  • 50.
  • 51.
    “Developers  who  bought  overwrote  this  method  typically  also  overwrote...” USAGE-­‐DRIVEN  JAVADOC
  • 52.
    In  good  documenta8on  we  trust... /** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */ @Override protected void doUnload() { super.doUnload(); } 32
  • 53.
    In  good  documenta8on  we  trust... /** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */ @Override protected void doUnload() { super.doUnload(); } 32
  • 54.
    In  good  documenta8on  we  trust... /** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */ @Override protected void doUnload() { super.doUnload(); } No?  Are  you  sure? 32
  • 55.
    In  good documenta8on  we  trust... good   /** * Rollsback the transaction if any and clears different lists to * start with an empty resource again. * Note that the super.doUnload is not called because that clears * the list resulting in all kinds of undesirable inverseremoves. */ @Override protected void doUnload() { super.doUnload(); } No?  Are  you  sure? 32
  • 56.
  • 57.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 58.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 59.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 60.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 61.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 62.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 63.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 33
  • 64.
    Genera8ng  high-­‐quality API  documenta8on high-­‐quality   /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  • 65.
    Genera8ng  high-­‐quality  API  documenta8on /** * The number of questions. */ private int numberOfQuestions; /** * Sets the number of questions. * * @param numberOfQuestions the number of questions * @throws IllegalArgumentException the illegal argument exception */ public void setNumberOfQuestions(int numberOfQuestions) throws IllegalArgumentException { if (numberOfQuestions < 0) { throw new IllegalArgumentException("numberOfQuestions < 0"); } this.numberOfQuestions = numberOfQuestions; } 34
  • 66.
    What  people  say  about  JAutodoc... 35
  • 67.
    What  people  say  about  JAutodoc... User: Anonymous Rating: 9 2009-08-02 11:32:37 Wow exactly what I needed! 35
  • 68.
    What  people  say  about  JAutodoc... User: Anonymous Rating: 9 2009-08-02 11:32:37 Wow exactly what I needed! User: Anonymous Rating: 9 2009-02-13 19:58:32 Thank you... this plugin rocks! 35
  • 69.
    What  people  say  about  JAutodoc... User: Anonymous Rating: 9 2009-08-02 11:32:37 Wow exactly what I needed! User: Anonymous Rating: 9 2009-02-13 19:58:32 Thank you... this plugin rocks! User: Anonymous Rating: 9 2009-02-13 19:58:32 Works perfectly. Smarter than I expected! 35
  • 70.
    What  people  say  about  JAutodoc... User: Anonymous Rating: 9 2009-08-02 11:32:37 Wow exactly what I needed! User: Anonymous Rating: 9 2009-02-13 19:58:32 Thank you... this plugin rocks! User: Anonymous Rating: 9 2009-02-13 19:58:32 Works perfectly. Smarter than I expected! WTH?  What  did  you  expect?! 35
  • 71.
    How  Recommenders  is  coming  to  rescue... 36
  • 72.
    Some  facts  about  the documenta8on  of  overridable  methods Overridable 2.074 Overridden 623 0 700 1400 2100 37
  • 73.
    What  clients  do  with  your  API... Overridden 623 Documented * 155 0 325 650 *  documented  as  overridable  by  using  phrases  like  “clients  may/should/must  override/extend  this  method” 38
  • 74.
    What  clients  do  with  your  API... Overridden 623 Documented * 155 478 0 325 650 *  documented  as  overridable  by  using  phrases  like  “clients  may/should/must  override/extend  this  method” 38
  • 75.
    What  documenta8on  would  you  expect  when   subclassing  Dialog? package org.eclipse.recommenders.examples.demo; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.window.IShellProvider; public class MyDialog extends Dialog { protected MyDialog(final IShellProvider parentShell) { super(parentShell); } } 39
  • 76.
  • 77.
    What  Javadoc  gives  you... A  dialog  is  a  specialized  window  used  for  narrow-­‐focused   communica8on  with  the  user.   40
  • 78.
    What  Javadoc  gives  you... A  dialog  is  a  specialized  window  used  for  narrow-­‐focused   communica8on  with  the  user.   Dialogs  are  usually  modal.  Consequently,  it  is  generally   bad  prac8ce  to  open  a  dialog  without  a  parent.  A  modal   dialog  without  a  parent  is  not  prevented  from   disappearing  behind  the  applica8on's  other  windows,   making  it  very  confusing  for  the  user.   If  there  is  more  than  one  modal  dialog  is  open  the  second   one  should  be  parented  off  of  the  shell  of  the  first  one   otherwise  it  is  possible  that  the  OS  will  cus  to  the  first   dialog  poten8ally  blocking  the  UI.   40
  • 79.
    What  Javadoc  gives  you... A  dialog  is  a  specialized  window  used  for  narrow-­‐focused   communica8on  with  the  user.   Dialogs  are  usually  modal.  Consequently,  it  is  generally   bad  prac8ce  to  open  a  dialog  without  a  parent.  A  modal   dialog  without  a  parent  is  not  prevented  from   But what are the disappearing  behind  the  applica8on's  other  windows,   making  it  very  confusing  for  the  user.   hot-spots of Dialog? If  there  is  more  than  one  modal  dialog  is  open  the  second   one  should  be  parented  off  of  the  shell  of  the  first  one   otherwise  it  is  possible  that  the  OS  will  cus  to  the  first   dialog  poten8ally  blocking  the  UI.   40
  • 80.
    What  code  comple8on  offers... 41
  • 81.
    What  code  comple8on  offers... Which of the 56 methods should we override? 41
  • 82.
    Recommending  method  overrides... publicclass MyDialog extends Dialog { 42
  • 83.
    Recommending  Self-­‐Calls public classMyDialog extends Dialog { @Override protected Control createDialogArea(Composite parent) { 43
  • 84.
    Mining  for  Subclassing  parerns public class MyViewerComparator extends ViewerComparator { 44
  • 85.
    Mining  example  code  snippets public class MyDialog extends Dialog { @Override protected Control createDialogArea(Composite parent) { 45
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
    How  it  works  -­‐  in  a  nutshell 49
  • 92.
    “Why  is  Google  Codesearch  not  ‘google  for  code  search’?  ” CODE-­‐SEARCH  ENGINES  LIFT  OFF
  • 93.
    How  many  request  per  minutes  do code  search  engines  have? 51
  • 94.
    20 Number  for  koders.com  in  2009  according  to    “Analyzing  and  mining  a  code  search  engine  usage  log” hrp://dx.doi.org/10.1007/s10664-­‐010-­‐9144-­‐6 52
  • 95.
    Naviga8ng  the  API  jungle… private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 53
  • 96.
    Naviga8ng  the  API  jungle… private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } How  to  solve String  -­‐>  ASTParser  -­‐>  CompilaLonUnit? 53
  • 97.
    When  asking  Google  code  search... 54
  • 98.
    When  asking  Google  code  search... 54
  • 99.
    When  asking  Google  code  search... 54
  • 100.
    When  asking  Google  code  search... 54
  • 101.
  • 102.
    Why? Text-based retrieval! 55
  • 103.
    Why? Text-based retrieval! Inexpressive query language! 55
  • 104.
    Why? Text-based retrieval! Inexpressive query language! Ignores prior knowledge! 55
  • 105.
    Why? Text-based retrieval! Inexpressive query language! Ignores prior knowledge! License Issues! 55
  • 106.
    Example  code  search  engine public class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 56
  • 107.
    Example  code  search  engine public class MyJavaEditor extends EditorPart { private CompilationUnit createCompilationUnit(String source) { // how can I create and configure an ASTParser? ASTParser parser = null; parser.setSource(source.toCharArray()); Query // ASTParser --> CompilationUnit: how? CompilationUnit cu = null; return cu; } 56
  • 108.
    “Why  is  Google  Codesearch  not  ‘google  for  code  search’?  ” LEVERAGING  USER  FEEDBACK  TO IMPROVE  CODE  SEARCH  ENGINES
  • 109.
  • 110.
  • 111.
    Refine  the  ranking  based  on  feedback 59
  • 112.
    Refine  the  ranking  based  on  feedback 59
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
    Ranking  the  examples document query feature-­‐score  i [0..1] 61
  • 118.
    Ranking  the  examples document query weight   feature-­‐score  i (-­‐∞..+∞) [0..1] 61
  • 119.
    Upda8ng  the  feature  weights... 62
  • 120.
    Upda8ng  the  feature  weights... 62
  • 121.
    Upda8ng  the  feature  weights... 10.000  ∗ 62
  • 122.
    Benefits  of  automated  tweaking #  kendall’s  ι #  queries baseline click-­‐through 63
  • 123.
    Interac8ons  diagram Client Server 1 Developer «triggers» 2 Search Invocation 3 Code Snippet Ranking Incomplete Source Code Query Ranking Search Function Index 4 Code Snippet Presentation Code «updates» Examples 5 Feedback Processing Code Code Summarization Highlighter Weights Learning Clickthrough Cli kth h Function data 64
  • 124.
    Applica8on  scenarios  for  your    company Open  Source Repositories 65
  • 125.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories 65
  • 126.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories 65
  • 127.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories 65
  • 128.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories 65
  • 129.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories Filesystem   65
  • 130.
    “People  that  bought  had  this  NullPointerExcepKon,  made  this  mistake:...” WHAT  CAUSED  THAT  STACKTRACE?
  • 131.
    So  far  we  have… 67
  • 132.
    So  far  we  have… Intelligent  Code  Comple8on 67
  • 133.
    So  far  we  have… Intelligent  Code  Comple8on Extended  Documenta8on 67
  • 134.
    So  far  we  have… Intelligent  Code  Comple8on Extended  Documenta8on Code  Example  Recommender How  do  I  get  an  instance  of…? 67
  • 135.
    So  far  we  have… Intelligent  Code  Comple8on Extended  Documenta8on Smart  Bug  Detec8on Code  Example  Recommender What  have  I  missed? How  do  I  get  an  instance  of…? 67
  • 136.
    But  what  if  you  get  this? 68
  • 137.
    Debugging  –  the  old  way 69
  • 138.
    Debugging  –  the  old  way 69
  • 139.
    Debugging  –  the  old  way 70
  • 140.
    But  more  ozen  we  get… 71
  • 141.
    How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali8es? 72
  • 142.
    How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali8es? 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) 72
  • 143.
    How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali8es? 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) 72
  • 144.
    How  can  we  fix  that?   Don’t  stacktraces  share  some  commonali8es? Excep8onType  Feature (evaluates  iden8cal  excep8on  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) 72
  • 145.
  • 146.
    Applica8on  scenarios  for  your    company Open  Source Repositories Company Repositories 74
  • 147.
    “IDE  2.0?  Leveraging  the  wisdom  of  the  (Eclipse)  community…” ECLIPSE  CODE  RECOMMENDERS
  • 148.
    A  developer’s  day... Switching Applications Edit Code Searching Code Testing Navigate Dependencies Reading API Doc Comprehend Task Handling Comprehending Interruptions Code Source:  Eclipse  Mylyn  Developer  Techtalk  2011,  IEEE  TSE,  Vol.  32,  No.  12,  2006 76
  • 149.
    From  IDE  1.0  to  IDE  2.0 77
  • 150.
    From  IDE  1.0  to  IDE  2.0 77
  • 151.
    Where  does  IDE  2.0  improve  the  process? Edit Code Testing Comprehend Task Handling Interruptions … 78
  • 152.
    Build  directly  from  version  control P2 79
  • 153.
    Leveraging  your  IDE’s  build  environment 80
  • 154.
    Leveraging  your  IDE’s  build  environment project environment 80
  • 155.
    Leveraging  your  IDE’s  build  environment context project environment 80
  • 156.
    Leveraging  your  IDE’s  build  environment context object usage project environment 80
  • 157.
    Leveraging  your  IDE’s  build  environment context object usage project selected environment proposals 80
  • 158.
    Leveraging  your  IDE’s  build  environment context object usage project selected environment proposals click feedback 80
  • 159.
    Leveraging  your  IDE’s  build  environment context object usage project selected environment proposals click feedback Stacktraces 80
  • 160.
  • 161.
    “Yours  is  ours  and  mine  is  mine...” BUT  HOW  ABOUT  PRIVACY?
  • 162.
    Usage  data  sharing  example import com.mycompany.*; import org.eclipse.*; public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); } 83 }
  • 163.
    Usage  data  sharing  example import com.mycompany.*; import org.eclipse.*; public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); } 83 }
  • 164.
    Informa8on  cleared  by  privacy  se{ngs import com.mycompany.*; import org.eclipse.*; public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); // lot of more things done with controller } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); } 84 }
  • 165.
    Effec8ve  usage  data  shared import com.mycompany.*; import org.eclipse.*; public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); } } }); return container; } @Override public void myCompanyServiceMethod() { controller.setup(); } 85 }
  • 166.
    Effec8ve  usage  data  shared import com.mycompany.*; import org.eclipse.*; public class MyCompanyDialog extends Dialog implements ICompanyService { MyCompanyController controller = new MyCompanyController(); @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); Button sync = new Button(container, SWT.CHECK); sync.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (sync.getSelection()) { controller.synchronize(); } Only  the  informaLon  how  you   }); } used  Eclipse  is  shared. return container; } @Override public void myCompanyServiceMethod() { controller.setup(); } 85 }
  • 167.
    “Support  your  own  framework.  Live  walk-­‐through...” RECOMMENDERS  FOR  ANDROID
  • 168.
  • 169.
    Summary Intelligent  Code  Comple8on Usage-­‐Driven  Javadocs Stacktrace  Search  Engine Smart  Bug  Detec8on Code  Example  Recommender What  caused  that  stacktrace? What  have  I  missed? How  do  I  get  an  instance  of…? 88
  • 170.
    Contributors  so  far… Jan   Kassens,     Peter  Schroeder,  Daniel  Glöckner,  Maik   Görtz,  Johannes   Lerch,  Johannes  Born,   Mohsen  Parisay,  Andreas  Sewe,  SebasLan  Ahlfeld,  SebasLan  Kasten,  Daniel  Staesche,  David   Kalnischkies,   SebasLan   Wörner,   Boyan   Yurukov,   Jan   Stolzenburg,   Nico   Wombacher,   Dirk   Kröhan,   Florianrian   Jakob,   Julius   Rückert,   Steffen   Remus,   Christopher   Mann,   Stefan   Henss,   Andreas   Kaluza,   Nikolay   Shindov,   Michael   Novotny,   KrisLn   Arand,   Sinem   Emeröz,   Michael   Kutschke,   SebasLan   Proksch,   Tomasz   Kalbarczyk,   Marko   MarLn,   Sheip   Dargutev,   David   Schuld,   Jens   Krause,   KrisLjan   Madunic,   Daniel   Brandtner,   Roman   GeTo,   ChrisLan   Kilb,   Johannes   Kastl,   Dennis   Sänger,   Annie   Liu,   Markus   Migenda,   Tjark   Vandommele,   SebasLan   Denel,  Florian  Nöll,   Gary  Fritz,  Dennis  Siebert,  Peter  Sinzig,  Laura  Altmüller,  Paul  Schatygin,   Jan-­‐Michael  Heller,  Minh  Hoang  Nguyen,  Sascha  Nordquist,  Paul  Emmanuel  Faidherbe,  ... 89
  • 171.
  • 172.
    Q  &  A Intelligent  Code  Comple8on Usage-­‐Driven  Javadocs Stacktrace  Search  Engine Smart  Bug  Detec8on Code  Example  Recommender What  caused  that  stacktrace? What  have  I  missed? How  do  I  get  an  instance  of…? 91
  • 173.
    It’s  there. hrp://eclipse.org/recommenders/ Follow  me  on  twirer:  @MarcelBruch google+:  +Marcel  Bruch 92