Swing to SWT and Back: Patterns for API Migration by Wrapping - - PowerPoint PPT Presentation
Swing to SWT and Back: Patterns for API Migration by Wrapping - - PowerPoint PPT Presentation
Swing to SWT and Back: Patterns for API Migration by Wrapping Thiago Tonelli Bartolomei Ralf L ammel Krzysztof Czarnecki University of Waterloo University of Koblenz-Landau September 15, 2010 Outline Outline 1 - API Migration 2 - Study
Outline
Outline
3
1 - API Migration 2 - Study Design 3 - Study Results 4 - Conclusion and Future Work
1 - API Migration
API Migration
5
Application API Source
Uses
API Migration
6
Application API Source
Uses
Target API
API Migration
7
Application API Source
Uses
Target API Modified Application
Rewrite Uses
API Migration
8
Application API Source
Uses
Target API Modified Application
Rewrite Uses
Wrapper
Wraps Implements Adapt
Related Work
API Migration
10
Application API Source
Uses
Target API Modified Application
Rewrite Uses
API Migration
11
Application API Source
Uses
Target API Modified Application
Rewrite Uses Chow,Notkin [ICSM96] Padioleau et al. [EuroSys08] Procedural
API Migration
12
Application API Source
Uses
Target API Modified Application
Rewrite Uses Chow,Notkin [ICSM96] Padioleau et al. [EuroSys08] Procedural la n et al. [ ] Nita,Notkin [IC 0] Simple OO
API Migration
13
Application API Source
Uses
Target API Modified Application
Rewrite Uses Chow,Notkin [ICSM96] Padioleau et al. [EuroSys08] Procedural la n et al. [ ] Nita,Notkin [IC 0] Simple OO el, iwan [ICSE0 ] Perkins [PASTE0 ] Upgrade
API Migration
14
Application API Source
Uses
Target API Wrapper
Wraps Implements Adapt
API Migration
15
Application API Source
Uses
Target API Wrapper
Wraps Implements Adapt r I Procedural to OO
API Migration
16
Application API Source
Uses
Target API Wrapper
Wraps Implements Adapt r I Procedural to OO a a l To Services
API Migration
17
Application API Source
Uses
Target API Wrapper
Wraps Implements Adapt r I Procedural to OO a a l To Services l i l I Upgrade
API Migration
18
Application API Source
Uses
Target API Wrapper
Wraps Implements Adapt
Limitations (Motivations)
Limitations (Motivations)
20
Simple APIs
Limitations (Motivations)
20
Simple APIs No Deep Inheritance Hierarchies
Limitations (Motivations)
20
Simple APIs No Deep Inheritance Hierarchies Simple Mappings
2 - Study Design
Research Questions
Research Questions
23
- 1. What are the design challenges faced by developers
when implementing wrapping layers around OO APIs?
Research Questions
23
- 1. What are the design challenges faced by developers
when implementing wrapping layers around OO APIs?
- 2. What are the solutions employed in practice?
Subjects
Subjects
25
SwingWT
31 Kloc
SWTSwing
65 Kloc
Subjects
26
v3.2.2, 90 Kloc
SWT
v1.4, 234 Kloc
Swing
Wraps Wraps
SwingWT
31 Kloc
SWTSwing
65 Kloc
Subjects
27
XOM2JDOM
7 Kloc v3.2.2, 90 Kloc
SWT
v1.4, 234 Kloc
Swing
Wraps Wraps
SwingWT
31 Kloc
SWTSwing
65 Kloc
Subjects
28
v1.2.1, 19 Kloc
XOM
v1.1, 9 Kloc
JDOM
Wraps
XOM2JDOM
7 Kloc v3.2.2, 90 Kloc
SWT
v1.4, 234 Kloc
Swing
Wraps Wraps
SwingWT
31 Kloc
SWTSwing
65 Kloc
Methodology
Methodology
30
- 1. Uncover design challenges
Methodology
30
- 1. Uncover design challenges
Source Code Original Developers Type Correspondences
Methodology
30
- 1. Uncover design challenges
Source Code Original Developers Type Correspondences
- 2. Understand solutions
Methodology
30
- 1. Uncover design challenges
Source Code Original Developers Type Correspondences
- 2. Understand solutions
Source Code Code Queries Design Patterns
Methodology
30
- 1. Uncover design challenges
Source Code Original Developers Type Correspondences
- 2. Understand solutions
Source Code Code Queries Design Patterns
- 3. Measure presence of design patterns
Methodology
30
- 1. Uncover design challenges
Source Code Original Developers Type Correspondences
- 2. Understand solutions
Source Code Code Queries Design Patterns
- 3. Measure presence of design patterns
Metrics
3 - Study Results
API Wrapping Challenges & Design Patterns
API Wrapping Challenges and Design Patterns
33
Challenge Design Pattern Non-trivial Mapping Multiplicities Layered Adapter Stateful Adapter Inversion of Control Inverse Delegation Correspondence of Object Identities Wrapping Identity Map Varying Creation and Wiring Protocols Delayed Instantiation Varying Type Hierarchies
ADAPTER Pattern
Java Vectors to ArrayLists
Vector to ArrayList
36
Application Vector
Vector to ArrayList
37
Application Vector
i cla Vector i Vector i void add Object i void setSize int
Vector to ArrayList
38
Application Vector
ro
Vector to ArrayList
39
Application Vector
ro
i cla Vector i Vector i void add Object i void setSize int
Vector to ArrayList
40
Application Vector Arra
ro
i cla Vector i Vector i void add Object i void setSize int
Vector to ArrayList
41
Application Vector Arra
ro
i cla Vector ArrayList ptee i Vector i void add Object i void setSize int
Vector to ArrayList
42
Application Vector Arra
ro
i cla Vector ArrayList ptee i Vector a ptee ArrayList i void add Object a ptee add o i void setSize int le a ptee size a ptee add le a ptee size a ptee
- ve
Sample GUI Application
Sample GUI Application
44
SWT Swing
SWT GUI
SWT GUI
46
SWT GUI
47
Shell
SWT GUI
48
Display Shell
SWT GUI
49
Display Shell List
data
SWT GUI
50
Display Shell List
data
SWT GUI
51
Display Shell List
data
SWT GUI
52
Display Shell List Sel i s
data
SWT GUI
53
Display Shell List Sel i s
data
Swing GUI
Swing GUI
55
Swing GUI
56
JFrame Container
Swing GUI
57
JFrame JScrollPane Container
Swing GUI
58
JFrame JScrollPane
data
a
Swing GUI
59
JFrame JScrollPane
data
a
Swing GUI
60
JFrame JScrollPane n
data
a
Swing GUI
61
JFrame JScrollPane n
- nListener
ListModel
data
Container
Swing GUI
62
JFrame JScrollPane JList JCheckBox JButton ActionListener ListModel
data
Container
Swing GUI
63
JFrame JScrollPane JList JCheckBox JButton ActionListener ListModel
data
Container
Mapping SWT to Swing
SWT to Swing
65
Display Shell List Sel i s
data
a l a st i s List
data
ai
SWT to Swing
66
Display Shell
SWT to Swing
67
Display Shell JFrame Container
SWT to Swing
68
Display Shell JFrame Container
SWT to Swing
69
Display Shell JFrame Container
isDisposed()
SWT to Swing
70
Display Shell List a ai
SWT to Swing
71
Display Shell List a l a st List
data
ai
SWT to Swing
72
Display Shell List a l a st List
data
ai
SWT to Swing
73
Display Shell List a l a st List
data
ai
SWT to Swing
74
Display Shell List a l a st List
data
ai
SWT to Swing
75
Display Shell List a l a st List
data
ai
SWT to Swing
76
Display Shell List a l a st List
data
ai
SWT to Swing
77
Display Shell List a l a st List
data
ai
SWT to Swing
78
Display Shell List a l a st List
data
ai
Non-trivial Mapping Multiplicities
Target Multiplicities
80
Name Example
No Target
Display→ ∅
Single Target
Vector→ArrayList
Alternative Targets
Button→JButton | JCheckBox
Composite Targets
List→JList, ListModel
Target Multiplicities
80
Name Example
No Target
Display→ ∅
Single Target
Vector→ArrayList
Alternative Targets
Button→JButton | JCheckBox
Composite Targets
List→JList, ListModel Alternative and Composite List → (JList, ListModel)|(JList, ListModel, JScrollPane)
Layered Adapter
Layered Adapter
82
ScrollableJListAdapter SimpleJListAdapter
Layered Adapter
82
ScrollableJListAdapter SimpleJListAdapter
Alternative and Composite List → (JList, ListModel)|(JList, ListModel, JScrollPane)
Stateful Adapter
Stateful Adapter
84
SWT to Swing
85
Display Shell List a l a st List
data
ai
SWT to Swing
86
Display Shell List Sel i s a l a st List
data
ai
SWT to Swing
87
Display Shell List Sel i s a l a st i s List
data
ai
SWT to Swing
88
Display Shell List Sel i s a l a st i s List
data
ai
Inversion of Control
Inverse Delegation
SWT to Swing
91
Display Shell List Sel i s a l a st i s List
data
ai
SWT to Swing
92
Display Shell List Sel i s a l a st i s List
data
ai
getChildren()
SWT to Swing
93
Display Shell List Sel i s a l a st i s List
data
ai
getChildren() getComponents()
SWT to Swing
94
Display Shell List Sel i s a l a st i s List
data
ai
getChildren() getComponents()
SWT to Swing
95
Display Shell List Sel i s a l a st i s List
data
ai
getChildren() getComponents()
Correspondence of Object Identities
Wrapping Identity Map
Wrapper Metrics
Wrapper Metrics
99
Wrapper
SwingWT SWTSwing XOM2JDOM
Layered Adapters 64 54 1 Stateful Adapter 98 181 13 Inverse Delegation 20 59 1 Wrapping Identity Map ✔ ✔ ✔ Delayed Instantiation ✔ ✘ ✘
4 - Conclusion and Future Work
Conclusion
Conclusion
102
Challenges of OO API Migration by Wrapping in practice
Conclusion
102
Challenges of OO API Migration by Wrapping in practice Solutions as design patterns
Future Work
Future Work
104
Validation of patterns in additional projects and domains
Future Work
104