Page 1
Stanford HCI Group Adobe Advanced Technology Labs
Two Studies ofOpportunistic Programming: Interleaving Web Foraging, Learning, and Writing Code
Joel Brandtwith Philip Guo (S), Joel Leweinstein (S), Mira Dontcheva (A), Scott
Klemmer (S),
http://hci.stanford.edu/opportunistic
Page 2
2
“good grief, I don’t even
remember the syntax for
forms!”
Page 15
15
The Web has fundamentally changed the cost structure
of information access.
Enables an opportunistic
approach to programming
Page 16
16
People program opportunistically to prototype, ideate, and discover
Emphasize speed and ease of development over code robustness
and maintainability
Page 17
17
http://flickr.com/photos/royalsapien/2387707860/
Designers…
Page 18
18
http://flickr.com/photos/niosh/2492023651/
Scientists…
Page 19
19
http://www.flickr.com/photos/samthor/3198975900/
Makers…
Page 20
20
By 2012:13 million who program as part of their job…
…but only 3 million who are
professional programmers
[Scaffidi 2005]
Page 21
21
How do programmers use online resources?
Page 22
22
Related WorkWeb Search for Programmers
[Stylos 06, Hoffmann 07]
Code Cloning in Software Engineering[Kim 04, Ducasse 99]
Learning Barriers of Programming[Ko 04]
Learning on the Web[Torrey 09]
Page 23
23
Study 1: Prototyping a
Web-based chat room
Study 2: Log Analysis of Programmers’
Web Queries
Page 24
24
Study 1: Web Chat Room 20 participants (9 Graduate, 11
Undergrad) “basic knowledge” of PHP, JS, and
HTML 2.5 hours each use any resources 3 researchers observed,
one asked questions to prompt think aloud
METHOD
Page 25
25
Chat Room Specifications
1. Set username
2. Post messages
3. Update without page reload
4. Messages have timestamp
5. Limited chat history
METHOD
Page 27
27
Most Subjects Met All Specs
� � � �� � � � �� � �� � � � �� � � � �� � � � �� � � � �� � � �� � � � �� � � � �� � � � �� � � �� � � � �� � � � �� � � �� � � � �� � � � �� � � � �� � � � �� � � � �
user
nam
epo
st m
essa
geAJ
AX u
pdat
etim
esta
mp
hist
ory
� Specification Met
� Specification Attempted
subj
ects
RESULTS
Page 28
28
Frequent Web Usesu
bjec
ts
time (minutes)
RESULTS
Page 29
29
Frequent Web Usesu
bjec
ts
time (minutes)
RESULTS
Page 30
30
Frequent Web Usesu
bjec
ts
time (minutes)
RESULTS
Page 31
31
Frequent Web Usesu
bjec
ts
time (minutes)
RESULTS
Page 32
32
The Web plays multiple roles
RESULTS
leng
th (s
econ
ds)
session (sorted by length)
Page 33
33
The Web plays multiple roles
RESULTS
leng
th (s
econ
ds)
session (sorted by length)
Page 34
34
The Web plays multiple roles
RESULTS
leng
th (s
econ
ds)
session (sorted by length)
Page 35
35
Three Intentions Behind Web UseLearning
just-in-time acquisition of new skills
Clarification connecting high-level knowledge to implementation details
Reminder offloading memory to external resources
RESULTS
Page 36
36
Just-in-Time Learning-by-DoingCopy and modify code before reading prose
RESULTS
Page 37
37
“There’s some stuff in this code that I don’t really know
what it’s doing, but I’ll just try it and
see what happens.”
Page 38
38
Just-in-Time Learning-by-DoingCopy and modify code before reading prose
Not concerned with deep learning
RESULTS
Page 39
39
“I think it’s less expensive for me to just take the first code I find and see how helpful it is at … a very high level … as
opposed to just reading all these
descriptions and text”
Page 40
40
Just-in-Time Learning-by-DoingCopy and modify code before reading prose
Not concerned with deep learning
Learn new terminology from result snippets
RESULTS
Page 41
41
Example Query
Terms
TimeNumber of
Refinements
Number of Result Clicks
Types of pages visited
Lines of code
copied
Page 42
42
Learning
Example Query
Terms
TimeNumber of
Refinements
Number of Result Clicks
Types of pages visited
Lines of code
copied
Page 43
43
Learning
Example Query ajax tutorial
Terms
TimeNumber of
Refinements
Number of Result Clicks
Types of pages visited
Lines of code
copied
Page 44
44
Learning
Example Query ajax tutorial
Terms English
TimeNumber of
Refinements
Number of Result Clicks
Types of pages visited
Lines of code
copied
Page 45
45
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
sNumber of
Result Clicks
Types of pages visited
Lines of code
copied
Page 46
46
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
Types of pages visited
Lines of code
copied
Page 47
47
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
Lines of code
copied
Page 48
48
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copied
Page 49
49
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 50
50
Clarification of Existing Knowledge
Web search enables translations and “language analogies”
Know exactly what code does when they see it
Copied code often not immediately tested
RESULTS
Page 51
51
Learning
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 52
52
Learning Clarification
Example Query ajax tutorial
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 53
53
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 54
54
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 55
55
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 56
56
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 57
57
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
Lines of code
copieddozens
Page 58
58
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens
Page 59
59
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 60
60
Reminding about forgotten details Explicitly choose not to learn
things Search serves as “Web-
enabled auto-complete”
RESULTS
Page 63
63
Reminding about forgotten details Explicitly choose not to learn
things Search serves as “Web-
enabled auto-complete” Despite utility, can break flow
RESULTS
Page 64
64
Learning Clarification
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 65
65
Learning Clarification Reminder
Example Query ajax tutorial javascript
thread
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 66
66
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 67
67
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 68
68
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 69
69
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1 0
Number of Result Clicks
5+ 1-2Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 70
70
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1 0
Number of Result Clicks
5+ 1-2 0-1Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
Lines of code
copieddozens several
Page 71
71
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1 0
Number of Result Clicks
5+ 1-2 0-1Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
API docs,result
snippetsLines of
code copied
dozens several
Page 72
72
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1 0
Number of Result Clicks
5+ 1-2 0-1Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
API docs,result
snippetsLines of
code copied
dozens several none to several
Page 73
73
How do these results generalize?
Page 74
74
Study 2: Query Log Analysis Adobe Community Help logs from July
2008 ~25,000 programmers performing
101,289 queries about Adobe Flex Framework
Grouped queries into 65,955 search sessions
Analyzed three properties of sessions: Format of query strings Process of query refinement Types of Web pages visited
Hand-coded 300 sessions for intent
METHOD
Page 75
75
Query format predicts types of pages visited
Page 76
76
Query format predicts types of pages visited
Page type code only English + code English only
Adobe APIs 38% 16% 10%Adobe tutorials 31% 33% 39%
blogs 15% 22% 19%forums 3% 7% 6%
unclassified 13% 22% 27%All inter-row differences significant at p < 0.001
RESULTS
Page 77
77
Query format predicts types of pages visited
Page type code only English + code English only
Adobe APIs 38% 16% 10%Adobe tutorials 31% 33% 39%
blogs 15% 22% 19%forums 3% 7% 6%
unclassified 13% 22% 27%
RESULTS
All inter-row differences significant at p < 0.001
Page 78
78
Query format predicts types of pages visited
Page type code only English + code English only
Adobe APIs 38% 16% 10%Adobe tutorials 31% 33% 39%
blogs 15% 22% 19%forums 3% 7% 6%
unclassified 13% 22% 27%
RESULTS
All inter-row differences significant at p < 0.001
Page 79
79
Query format predicts types of pages visited
Page type code only English + code English only
Adobe APIs 38% 16% 10%Adobe tutorials 31% 33% 39%
blogs 15% 22% 19%forums 3% 7% 6%
unclassified 13% 22% 27%
RESULTS
All inter-row differences significant at p < 0.001
Page 80
80
Reminder sessions are typically code-only queries
Page 81
81
Query format indicative of intention
query format reminding learning
code only 56% 21%English + code 10% 29%
English only 34% 50%
RESULTS
All inter-row differences significant at p < 0.05
Page 82
82
Programmers rarely need to refine queries
Page 83
83
Programmers refine rarely
RESULTS
num
ber
of q
uerie
s
query number in session
Page 84
84
…and they start out with either words or code
RESULTS
perc
ent o
f que
ries
query number in session
Page 85
85
Five Key Insightsfor Tool Design
Page 86
86
Just-in-time learning is common
Create tutorials that teach “how the code works”
Page 87
87
Copied code often not immediately tested
Demarcate copied code,highlight what is executed
Page 88
88
Web search often used as a “translator”
Improve search ranking with synonyms,
perform searches automatically
Page 89
89
Programmers choose not to learn syntax
Make Web-enabled auto-complete
Page 90
90
Query refinement is often predictable
Automatically augment queries
Page 91
91
Preview of Ongoing Work
BlueprintEnabling Example-Centric Programming
Page 94
Stanford HCI Group Adobe Advanced Technology Labs
http://hci.stanford.edu/opportunistic
Page 96
96
Learning Clarification Reminder
Example Query ajax tutorial javascript
threadfetch_array
php
Terms English mix of code and English mostly code
Time 10s of minutes
about 1 minute
less than 1 minute
Number of Refinement
s2-3 0-1 0
Number of Result Clicks
5+ 1-2 0-1Types of
pages visited
tutorials, how-to articles
API docs, blogs, forums
API docs,result
snippetsLines of
code copied
dozens several none to several