Improving Refactoring with Alternate Program View

Download Report

Transcript Improving Refactoring with Alternate Program View

MULTIVIEW
Improving Refactoring with
Alternative Program Views
Emerson Murphy-Hill
1
MULTIVIEW
The Problem with Software
Development Tools
Software development tools could be a great boon
to productivity and program correctness.
But current tools can be difficult to use, so much so
that developers may be discouraged from using
them.
How can we improve tools so that programmers
are more likely to understand and adopt them?
2
• Introduction to Refactoring
• Usability Problems with Current
Refactoring Tools
• New, More Usable Refactoring Tools
• An Experiment to Compare Current to
New Refactoring Tools
• Conclusions
MULTIVIEW
Outline
3
MULTIVIEW
Introduction to Refactoring
• Refactoring is restructuring programs while
preserving behavior
• Examples: renaming variables and methods,
encapsulating instance variables, inline method…
• Refactoring is good for:
– Making programs more understandable
– Allowing features to be added more easily
– Keeping program development agile
• Automated Tools  Behavior-Preservation
4
• Take a list of statements, move them to a
new method, then replace the original
statements with a call to the new method
• (demo)
MULTIVIEW
Extract Method: Crossing
Refactoring’s Rubicon
5
“method of same
name already
exists…”
Change name of
other method
Fix
Code
Identify
Code
Select
Code
Interpret
Error
Configure
Refactoring
Error!
Apply
Refactoring
MULTIVIEW
Refactoring Process with Tools
Debrief
OK
Pick a Code
Select the
Choose(Tool
a
executesOptional:
Segment
Code Segment
Name for code
the change)
Inspect the
New Method
New Method
6
• Introduction to Refactoring
• Usability Problems with Current
Refactoring Tools
• New, More Usable Refactoring Tools
• An Experiment to Compare Current to
New Refactoring Tools
• Conclusions
MULTIVIEW
Outline
7
MULTIVIEW
What problems do programmers
have during Extract Method?
• Performed an exercise with programmers, mostly
from this department
– 9 of 11 programmers encountered an error during
Extract Method
– One programmer succeeded in only 11 of 34 attempts
to extract a method
– Programmers frequently had problems selecting whole
statements
– Programmers had problems understanding error
messages
– Errors discouraged the programmer from refactoring
8
• Introduction to Refactoring
• Usability Problems with Current
Refactoring Tools
• New, More Usable Refactoring Tools
• An Experiment to Compare Current to
New Refactoring Tools
• Conclusions
MULTIVIEW
Outline
9
• Based on the
formative exercise, I
created three views to
improve the process
• Two for Selection
– “Selection Assist”
– “Box View”
Identify
Code
Fix
Code
Select
Code
Interpret
Error
Configure
Refactoring
MULTIVIEW
Some Tool Improvements
Error!
Apply
Refactoring
• One for Interpreting
Errors
Debrief
OK
– “Refactoring
Annotations”
Tools are available at http://multiview.cs.pdx.edu/refactoring
10
• Important Qualities of this View:
MULTIVIEW
Selection Assist
– It’s lightweight – doesn’t slow down the
common case
– Programmer selection time is proportional to
statement length
– Programmer can use keyboard or mouse
11
MULTIVIEW
Tools Similar to Selection Assist
12
• Important Qualities of this View:
MULTIVIEW
Box View
– Abstracts away code formatting
– Selection time is constant for any statement
– Programmer can use keyboard or mouse
13
Adobe GoLive
MULTIVIEW
A Tool Similar to Box View
14
• Important Qualities of this View:
–
–
–
–
–
Indicates the location of errors
Indicates errors relationally (colors, arrows)
Indicates every error (overlaid)
Errors cues are distinguishable
Indicates the amount of work required to recover
from error
– Distinguishes showstoppers (Xs) from advisories
MULTIVIEW
Refactoring Annotations
15
Eclipse
Control Structure Diagrams
MULTIVIEW
Tools Similar to Refactoring Annotations
Dr. Scheme
16
• Introduction to Refactoring
• Usability Problems with Current
Refactoring Tools
• New, More Usable Refactoring Tools
• An Experiment to Compare Current to
New Refactoring Tools
• Conclusions
MULTIVIEW
Outline
17
Old Tools New Tools
Keyboard/Mouse
Eclipse Extract Method Wizard
Selection Assist
Box View
MULTIVIEW
Experiments: Compare Tools
Refactoring Annotations
Subjects were 16 students from
Professor Black’s Object-Oriented
programming class.
18
• Question
– Which selection tools help programmers select
statements most accurately and quickly?
MULTIVIEW
Selection Experiment
• Methodology
– Subjects select all if statements in real code, assisted by
Keyboard/Mouse, Selection Assist, and Box View
• Measurements
– Whether each if statement was selected correctly
– The time between consecutive selections
19
*All Users Combined*
Mis-Selected
If Statements
Correctly
Selected If
Statements
Mean selection
time (seconds)
Normalized
Selection Time
37
303
10.4
100%
Selection Assist
6
355
5.5
54%
Box View
2
357
7.8
71%
Mouse/Keyboard
MULTIVIEW
Selection Results
20
MULTIVIEW
Subjects’ Opinions
– 31% said the mouse/keyboard was helpful
– 94% said Selection Assist was helpful
– 81% said Box View was helpful
– 94% said they were likely to use Selection Assist again
– 63% said they were likely to use Box View again
21
• Question
– Which Extract Method tools help programmers
understand errors most accurately and quickly?
• Methodology
MULTIVIEW
Extraction Experiment
– Subjects are given an un-extractable method and told
to identify the location of each error using the Eclipse
Extract Method Wizard and Refactoring Annotations
• Measurements
– Whether each error was identified correctly
– How long it takes to identify all errors correctly
22
*All Users Combined*
Eclipse Wizard
Refactoring
Annotations
Failed to Identify
Error
Identified Nonerror
Mean
Elapsed Time
(seconds)
11
28
164
1
6
46
MULTIVIEW
Extraction Results
23
– 56% said Eclipse Wizard was helpful
– 100% said Refactoring Annotations were Helpful
MULTIVIEW
Subjects’ Opinions
– 62% were likely to use Eclipse Wizard again
– 100% were likely to use Refactoring Annotations again
24
• Programmers are less error prone and
faster using Box View and Selection Assist
• Programmers like using Box View and
Selection Assist
• Box View is good when likelihood of misselection is high
• Selection Assist is good for short code
blocks
MULTIVIEW
Interpretation of Results (1 of 2)
25
MULTIVIEW
Interpretation of Results (2/2)
• Programmers are more likely to understand
errors and understand them faster using
Refactoring Annotations
• Programmers REALLY like using Refactoring
Annotations
26
MULTIVIEW
My Contributions
• I have shown that the traditional view used by
programmer tools can impede refactoring
• I have introduced alternative views to address
specific problems
• I have demonstrated that these views measurably
improve the refactoring process
Future Work
More user-friendly software development tools may help
increase tool adoption, and then yield more
productive programmers and less buggy software
27
MULTIVIEW
Thanks…
• Advice on Experimental Design: Suresh Singh and
Jim Larson
• General Advice and Paper Reviews: Robert Bauer,
Paul Berry, Andrew Black, Iavor Diatchki, Tom
Harke, Brian Huffman, Mark Jones, Chuan-kai
Lin, Ralph London, Philip Quitslund, Tim Sheard,
and Aravind Subhash
• Special thanks to colleagues and students who
participated in testing.
• Practice talk reviewers
28
MULTIVIEW
References
Fowler, M., Beck, K., Brant, J., Opdyke, W. and Roberts, D.: Refactoring:
Improving the Design of Existing Code. Addison-Wesley Professional
(1999)
Fowler, M. Crossing Refactoring's Rubicon.
http://www.martinfowler.com/articles/refactoringRubicon.html, (2001)
The Eclipse Foundation: Eclipse, http://www.eclipse.org, accessed November
2005
Findler, R., Clements, J., Matthew, Krishnamurthi, S., Steckler, P. and Felleisen,
M.: DrScheme: A Progamming Environment for Scheme. Journal of
Functional Programming, 12(2):159-182, (2002)
Adobe Systems Incorporated: Adobe GoLive.
http://www.adobe.com/products/golive, accessed November 2005
Hendrix, D., Cross, J., Maghsoodloo, S. and McKinney, M.: Do Visualizations
Improve Program Comprehensibility? Experiments with Control Structure
Diagrams for Java. Haller, S. (ed.): In Proc. Thirty-First SIGCSE Technical
Symposium on Computer Science Education, Vol. 32. pp. 382-386. ACM,
Austin, Texas (2000)
29
MULTIVIEW
Questions?
30
17
15
15
13
11
9
7
5
3
MULTIVIEW
17
Selection time (seconds) with Box View
Selection time (seconds) with Selection Assist
Per-Subject Selection Results
13
11
9
7
5
3
3
5
7
9
11
13
15
Selection tim e (seconds) w ith Mouse/Keyboard
17
3
5
7
9
11
13
15
17
Selection tim e (seconds) w ith Mouse/Keyboard
31
MULTIVIEW
Per Subject Extraction Results
32
I found the mouse/keyboard alone a helpful mechanism for selecting if blocks.
0
9
1
5
0
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
MULTIVIEW
Helpfulness of Selection Tools
I found the selection assist tool (green statement highlighter) a helpful mechanism for selecting
if blocks.
0
1
0
5
10
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
I found the statement box view (nested boxes off to the side of the code) a helpful mechanism
for selecting if blocks.
0
0
3
7
6
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
33
I found the extract method wizard (popups that contained an error message) a helpful
indication of what went wrong when I tried to extract a method.
0
3
3
6
3
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
MULTIVIEW
Helpfulness of Extraction Tools
I found the extract method annotations (colors/lines on top of code) a helpful indication of
what went wrong when I tried to extract a method
0
0
0
3
13
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
34
If the selection assist tool (green statement highlighter) were available for my
usual development environment, I would be likely to use it again.
0
0
1
3
12
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
MULTIVIEW
Likely-to-use-again: Selection Tools
If the statement box view (nested boxes off to the side of the code) were
available for my usual development environment, I would be likely to use it
again.
0
3
3
6
4
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
35
If the extract method wizard (popups that contained an error message) were
available for my usual development environment, I would be likely to use them
again during the extract method refactoring.
1
1
4
7
3
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
MULTIVIEW
Likely-to-use-again: Extraction Tools
If the extract method annotations (colors/lines on top of code) were available
for my usual development environment, I would be likely to use them again
during the extract method refactoring.
0
0
0
1
15
Strongly Disagree
Disagree
Neutral
Agree
Strongly Agree
36