Wissenstransfer 2.0: Liest du noch, oder programmierst du schon?
The knowledge transfer company
• Project Lead of Eclipse Code Recommenders • Eclipse Committer since 2010 • Plug-in Developer for 10 years (Eclipse 2.1) • Member of the Eclipse Architecture Council • Co-Lead of Java User Group Darmstadt • Speaker at JUGs, EclipseCon, JAX, JavaOne… • PhD in Computer Science • CEO of Codetrails
!• Passion to improve developers day-to-day work
with intelligent and practical tools - mostly using Data Mining on Big (Software Engineering) Data.
About Me
2
@MarcelBruch +MarcelBruch
Codetrails at a Glance
• The company behind Eclipse Code Recommenders
• Eclipse RCP Experts & Consultants
• Software Tool Developers
• Data Mining Specialists
• Research Spin-off Darmstadt University of Technology
3
supported by
About Eclipse Code Recommenders
4
2006 2009 2011
2012 2013 2014
Research begins
CR published CR goes
Eclipse
CR 1.0 Part of IDE CR 2.0 CR 2.1
Awards & Traction
5
2012
• >3.000.000 downloads
Top 20
• Talks at 50+ Democamps, Eclipse Days, and Java User Groups all over Europe.
• Talks at 10+ intl. and local conferences.
• articles every 4 months, • lots of general coverage
PROBLEM
Problem #1: Knowledge Drain
7
Problem #1: Knowledge Drain
8
Problem #1: Knowledge Drain
9
Software
Problem #2: Continuous Learning
10
A typical developer day
11
Comprehend Task 3 %
Handling Interruptions 20 %
Navigate Code 14 %
Study Code 19 %
Searching Web 12 %
Reading Docs 6 %
Write Code 27 %
51% of their time, developers invest in searching and understanding code
How we search
12
What developers look for
13Question + Answer + Code Example = ✓
A typical developer day
14
Comprehend Task 3 %
Handling Interruptions 20 %
Navigate Code 14 %
Study Code 19 %
Searching Web 12 %
Reading Docs 6 %
Write Code 27 %
Even when writing code we search…
If we don’t google…
15
1 of 387 ?
17
Code Completion
Frequency : 100 completions / day
Duration (⌀) : 27 seconds / completion
Sum : 45 minutes / day
9% of their time developers spent searching in their code completion
Problem
18
Comprehend Task 3 %
Handling Interruptions 20 %
Searching Code 12 %
Navigate Code 14 %
Reading Code 19 %
Reading Docs 6 %
Edit Code 27 %
Problem
19
Comprehend Task 3 %
Handling Interruptions 20 %
Searching Code 12 %
Navigate Code 14 %
Reading Code 19 %
Reading Docs 6 %
Edit Code 27 %
• 51% of their time, developers spent searching the web and existing code for help
• In addition, even when programming, they spent 9% searching in their code completion
• In total, 60% is about finding the right information to solve a programming task
SOLUTION„Leveraging the power of the crowds“
Behind every answered question…
21
… there is some code
22
Use the code
23
INTELLIGENT CODE COMPLETION„Other developers frequently bought used the following methods…“
@Override!protected Control createDialogArea(final Composite parent) {! Composite container = (Composite) super.createDialogArea(parent);! ! swtTextWidget = new Text(container, SWT.BORDER);! swtTextWidget.|! return container;!}
Code Completion…
What does the developer need, i.e., which methods should the code completion present to the user?
25
All 164 Methods of Text ?
Intelligent Code Completion
What your team really needs to know…
27
Snippet Completion (1)
28
HOW IT WORKS„Finding the hidden gems in your code“
class Example extends Page {! Text t;!! @Override! void createContents() {! t = new Text();! t.setText(..);! ...! }! ...!}
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
… … … … … … …
0 0 0 …
30
1 1 1
From code to models...
in:Page.createContents()
31
class Example extends Page {! Text t;! ...!! @Override! void performOk() {! t.getText();! ...! }!!}
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
1 0 1 1
1 1
0 0
0 0 0 0… … … … … …
……
…
From code to models...
in:Page.createContents()
32
class MyPage extends Page {!! Text t;! @Override! void createContents() {! t = new Text();! t.|<^space>! }! ...!}
1 …1 ?? ?0
From models to recommendations...
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
in:Page.createContents()
33
1 …1 ?? ?0
in:Page.performOk()
Text.<init>()
Text.getText()
Text.setFont()
...
Text.setText()
01 10 0 …1 10 0 0 0
… … … … … ………
1
0 1 1 1 0 …101 00 0 …1
⅔ ⅓ 0
From models to recommendations...
in:Page.createContents()
CALL-CHAIN COMPLETION“Welcome to the jungle...”
public class MyView extends ViewPart {! ! public void updateMessage(final String newMessage) {!! // How do I get an instance of IStatusLineManager?! final IStatusLineManager manager = |!! }
How to obtain an instance of...
There is no trivial solution. Again, what should code completion return?
35
What we need...
36
ViewPart
IViewSite
IAc-onBars
IStatusLineManager
getStatusLineManager()
getAc-onbars()
getViewSite()public void updateMessage(final String newMessage) {!! // How do I get an instance of ! ! final IStatusLineManager manager = ! this! .getViewSite()! .getActionBars()! .getStatusLineManager();!! manager.setMessage(newMessage);!}
SUBWORDS COMPLETION“BecausePureCamelCaseMatching****s!”
Use speaking names...?
38
When letters become just guidelines...
39I Like?Source: http://vimeo.com/19369928
EXTENDING API DOCUMENTATION“Developers who bought overwrote this method typically also overwrote...”
In good documentation we trust...
41
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?
Generating high-quality API documentation
42
/**! * 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;! }
What people say about JAutodoc...
43
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?!
How Recommenders is coming to rescue...
44
What documentation would you expect when subclassing Dialog?
45
package org.eclipse.recommenders.examples.demo;!!import org.eclipse.jface.*;!!public class MyDialog extends Dialog {!! protected MyDialog(final IShellProvider parentShell) {! super(parentShell);! } !}!!
What Javadoc gives you...
46
A dialog is a specialized window used for narrow-focused communication with the user. !Dialogs are usually modal. Consequently, it is generally bad practice to open a dialog without a parent. A modal dialog without a parent is not prevented from disappearing behind the application's other 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 potentially blocking the UI.
But what are the hot-spots of Dialog?
org.eclipse.jface.dialogs.Dialog
What code completion offers...
47
Which of the 56 methods should we override?
Recommending method overrides...
48
! public class MyDialog extends Dialog {!!
Recommending self-calls
49
public class MyWizard extends Wizard {!!! @Override! public void addPages() {! ! };
Mining for subclassing patterns
50
!public class MyViewerSorter extends ViewerComparator {
Mined example code snippets…
51
! public class MyDialog extends Dialog {! ! @Override! protected Control createDialogArea(Composite parent) {!!
SNIPMATCH„Stop searching Stackoverflow for code snippets“
Why do you use code templates?
53
Safe time typing
54
<ctrl+space>
<ctrl+space>
{<ctrl+space>
<ctrl+space>
}
Learning from snippets
55
Eclipse Java Templates
56
42x Java Templates. 35x SWT Templates.
Learning from snippets
57
The rise of code snippet repositories
58
and many more...
Snipmatch
59Recommenders
2.1
AND IF THERE IS NO CODE TO ANALYZE?„From code analysis to crowd sourcing“
Being for Software DevelopersHow 39 million click events make your IDE a smarter place
62
63
The amazon success factors
64
65
How about applying the very same principles to software development?
So, instead of using the web browser…
66
68
!!!
Disclaimer !
Data sharing is involved!
!
Not Eclipse anymore!
Crowdsourced Code CompletionDevelopers that bought used a StringBuilder, typically…
69
A fairly trivial example…
70
Instead saying…
71
What if we‘d just count calls...?
72Codetrails Connect Community Edition, Install from http://www.codetrails.com/connect
!void ctor() {! List l = new A…}
Crowdsourced Constructor Completion
73
What is the mostly likely completion a developer looks for in this particular situation ?
74
1 out of 302
!void ctor() {! List l = new A…}
Use (costly) subtype checks
75
Codetrails Completion Tweaks for Eclipse, Install from http://download.codetrails.com/updates/connect/
Crowdsourcing constructor completions...?
76
It learns from you. From the very 1st moment.
Codetrails Connect Community Edition, Install from http://download.codetrails.com/updates/connect/
public class MyDialog extends Dialog {! |!!
Crowdsourcing override completions...?
77
!void quickfix() {! List l = new A}
How about fixing quick-fix?
78Not fixed yet. But could be easily - when you start sharing your knowledge…
39.000.000 clicks for a smarter IDE
79Read more (October 2013) http://www.codetrails.com/blog/powered-33-million-code-completions-codetrails-connect-12
Method Overrides 1.579.303
Constructor Calls 8.915.540
Method Calls 38.254.438
48.749.281
Bootstrapped with30++ GB Java Bytecode. Powered by Maven Central and EclipseSource Yoxos.
56.424 crowdsourced completion events
80
org.eclipse.* 11 %org.apache.*
4 %com.google.*
9 %
com.vaadin.* 5 %
com.codetrails.* 3 %
others 14 %
javax.* 3 %
java.[n]io.* 6 %
java.util.* 25 %
java.lang.* 21 %
From December 22 to March 12
Trend: Events sent by the community
81
Visit the Codetrails Connect live dashboard: http://download.codetrails.com/connect/dashboard/
How well does it work?
82
What do you expect?
How well does it work?
83
Num
ber o
f pro
posa
ls m
ade
1
2
3
4
5
6
7
Position in code completion window-1 0 1 2 3 4 5 6
993
475
304
214
189
123
1.094
833
327 238
197 114 87
145 56 40 38
96 61 23 22 21
77 52 19 21 20 10
963 591 373 243 285 151 157
HitMiss
not found
Successfully concluded sessions
84
Codetrails 78,8
JDT 67,9
JDT standalone vs. Codetrails
Developers find what they need 11% more often with smart code completion. Number of documentation lookups saved in 3 months: 3.000!
What get’s shared?
85
What is shared?
86
{!„type“: „StringBuilder“,!„completion“: „append(String)“!
}
Sharing Preferences
87
Still scared of crowdsourcing?
88
Do you also suffer from Anatidaephobia?„Big Brother is watching you“ http://anniemachon.ch/annie_machon/2013/11/cryptofestival-london-30th-november.html
89
ANATIDAEPHOBIA IS THE FEAR THAT SOMEWHERE IN THE WORLD, THERE IS A DUCK WATCHING YOU.
90
https://vaadin.com/blog/-/blogs/crowdsourcing-vaadin-with-codetrails-connect
91
Snippets going social
5 0
Enriching Javadoc
92Eclipse Code Recommenders Livedoc 0.8 Incubator Install from http://eclipse.org/recommenders/incubators
Javadocs with mined snippets
93http://download.codetrails.com/livedoc/published/latest/org/eclipse/jface/org.eclipse.jface/3.8.102/
94
Breaking News:!Words carry meaning!As leading scientists found out, words....
Rethinking Recommendations
for Code Completion
A simple observation
95
You wouldn‘t expect a call to #dispose() in #createSomething(), right?
What you expect is...
96
How many words do you have for ‟create” ?
97
So, it works for #createSomething too!
98
Almost no difference!
99
Prec
isio
n
0
25
50
75
100
Recall
0 10 20 30 40 50 60 70 80 90 100
ClassicVerbs
Interpolated Precision Recall Curves over 136.761 samples on JRE
What get‘s shared?
100
{!„method“: „create“!„type“: „Composite“,!„completion“: „setLayout(...)“!
}
Let‘s back up here for a second!
101
We get (almost) language agnostic!
102
Read More
103
Installation
104
WRAP UP„Closing notes“
All that only happens if you share…
106
107
Yes, there is a duck somewhere.
108But it probably doesn’t care what you are doing.
THANK YOU
@MarcelBruch +MarcelBruch