Swing to SWT and Back: Patterns for API Migration by Wrapping - - PowerPoint PPT Presentation

swing to swt and back patterns for api migration by
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Outline

slide-3
SLIDE 3

Outline

3

1 - API Migration 2 - Study Design 3 - Study Results 4 - Conclusion and Future Work

slide-4
SLIDE 4

1 - API Migration

slide-5
SLIDE 5

API Migration

5

Application API Source

Uses

slide-6
SLIDE 6

API Migration

6

Application API Source

Uses

Target API

slide-7
SLIDE 7

API Migration

7

Application API Source

Uses

Target API Modified Application

Rewrite Uses

slide-8
SLIDE 8

API Migration

8

Application API Source

Uses

Target API Modified Application

Rewrite Uses

Wrapper

Wraps Implements Adapt

slide-9
SLIDE 9

Related Work

slide-10
SLIDE 10

API Migration

10

Application API Source

Uses

Target API Modified Application

Rewrite Uses

slide-11
SLIDE 11

API Migration

11

Application API Source

Uses

Target API Modified Application

Rewrite Uses Chow,Notkin [ICSM96] Padioleau et al. [EuroSys08] Procedural

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

slide-14
SLIDE 14

API Migration

14

Application API Source

Uses

Target API Wrapper

Wraps Implements Adapt

slide-15
SLIDE 15

API Migration

15

Application API Source

Uses

Target API Wrapper

Wraps Implements Adapt r I Procedural to OO

slide-16
SLIDE 16

API Migration

16

Application API Source

Uses

Target API Wrapper

Wraps Implements Adapt r I Procedural to OO a a l To Services

slide-17
SLIDE 17

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

slide-18
SLIDE 18

API Migration

18

Application API Source

Uses

Target API Wrapper

Wraps Implements Adapt

slide-19
SLIDE 19

Limitations (Motivations)

slide-20
SLIDE 20

Limitations (Motivations)

20

Simple APIs

slide-21
SLIDE 21

Limitations (Motivations)

20

Simple APIs No Deep Inheritance Hierarchies

slide-22
SLIDE 22

Limitations (Motivations)

20

Simple APIs No Deep Inheritance Hierarchies Simple Mappings

slide-23
SLIDE 23

2 - Study Design

slide-24
SLIDE 24

Research Questions

slide-25
SLIDE 25

Research Questions

23

  • 1. What are the design challenges faced by developers

when implementing wrapping layers around OO APIs?

slide-26
SLIDE 26

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?
slide-27
SLIDE 27

Subjects

slide-28
SLIDE 28

Subjects

25

SwingWT

31 Kloc

SWTSwing

65 Kloc

slide-29
SLIDE 29

Subjects

26

v3.2.2, 90 Kloc

SWT

v1.4, 234 Kloc

Swing

Wraps Wraps

SwingWT

31 Kloc

SWTSwing

65 Kloc

slide-30
SLIDE 30

Subjects

27

XOM2JDOM

7 Kloc v3.2.2, 90 Kloc

SWT

v1.4, 234 Kloc

Swing

Wraps Wraps

SwingWT

31 Kloc

SWTSwing

65 Kloc

slide-31
SLIDE 31

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

slide-32
SLIDE 32

Methodology

slide-33
SLIDE 33

Methodology

30

  • 1. Uncover design challenges
slide-34
SLIDE 34

Methodology

30

  • 1. Uncover design challenges

Source Code Original Developers Type Correspondences

slide-35
SLIDE 35

Methodology

30

  • 1. Uncover design challenges

Source Code Original Developers Type Correspondences

  • 2. Understand solutions
slide-36
SLIDE 36

Methodology

30

  • 1. Uncover design challenges

Source Code Original Developers Type Correspondences

  • 2. Understand solutions

Source Code Code Queries Design Patterns

slide-37
SLIDE 37

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
slide-38
SLIDE 38

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

slide-39
SLIDE 39

3 - Study Results

slide-40
SLIDE 40

API Wrapping Challenges & Design Patterns

slide-41
SLIDE 41

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

slide-42
SLIDE 42

ADAPTER Pattern

slide-43
SLIDE 43

Java Vectors to ArrayLists

slide-44
SLIDE 44

Vector to ArrayList

36

Application Vector

slide-45
SLIDE 45

Vector to ArrayList

37

Application Vector

i cla Vector i Vector i void add Object i void setSize int

slide-46
SLIDE 46

Vector to ArrayList

38

Application Vector

ro

slide-47
SLIDE 47

Vector to ArrayList

39

Application Vector

ro

i cla Vector i Vector i void add Object i void setSize int

slide-48
SLIDE 48

Vector to ArrayList

40

Application Vector Arra

ro

i cla Vector i Vector i void add Object i void setSize int

slide-49
SLIDE 49

Vector to ArrayList

41

Application Vector Arra

ro

i cla Vector ArrayList ptee i Vector i void add Object i void setSize int

slide-50
SLIDE 50

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
slide-51
SLIDE 51

Sample GUI Application

slide-52
SLIDE 52

Sample GUI Application

44

SWT Swing

slide-53
SLIDE 53

SWT GUI

slide-54
SLIDE 54

SWT GUI

46

slide-55
SLIDE 55

SWT GUI

47

Shell

slide-56
SLIDE 56

SWT GUI

48

Display Shell

slide-57
SLIDE 57

SWT GUI

49

Display Shell List

data

slide-58
SLIDE 58

SWT GUI

50

Display Shell List

data

slide-59
SLIDE 59

SWT GUI

51

Display Shell List

data

slide-60
SLIDE 60

SWT GUI

52

Display Shell List Sel i s

data

slide-61
SLIDE 61

SWT GUI

53

Display Shell List Sel i s

data

slide-62
SLIDE 62

Swing GUI

slide-63
SLIDE 63

Swing GUI

55

slide-64
SLIDE 64

Swing GUI

56

JFrame Container

slide-65
SLIDE 65

Swing GUI

57

JFrame JScrollPane Container

slide-66
SLIDE 66

Swing GUI

58

JFrame JScrollPane

data

a

slide-67
SLIDE 67

Swing GUI

59

JFrame JScrollPane

data

a

slide-68
SLIDE 68

Swing GUI

60

JFrame JScrollPane n

data

a

slide-69
SLIDE 69

Swing GUI

61

JFrame JScrollPane n

  • nListener

ListModel

data

Container

slide-70
SLIDE 70

Swing GUI

62

JFrame JScrollPane JList JCheckBox JButton ActionListener ListModel

data

Container

slide-71
SLIDE 71

Swing GUI

63

JFrame JScrollPane JList JCheckBox JButton ActionListener ListModel

data

Container

slide-72
SLIDE 72

Mapping SWT to Swing

slide-73
SLIDE 73

SWT to Swing

65

Display Shell List Sel i s

data

a l a st i s List

data

ai

slide-74
SLIDE 74

SWT to Swing

66

Display Shell

slide-75
SLIDE 75

SWT to Swing

67

Display Shell JFrame Container

slide-76
SLIDE 76

SWT to Swing

68

Display Shell JFrame Container

slide-77
SLIDE 77

SWT to Swing

69

Display Shell JFrame Container

isDisposed()

slide-78
SLIDE 78

SWT to Swing

70

Display Shell List a ai

slide-79
SLIDE 79

SWT to Swing

71

Display Shell List a l a st List

data

ai

slide-80
SLIDE 80

SWT to Swing

72

Display Shell List a l a st List

data

ai

slide-81
SLIDE 81

SWT to Swing

73

Display Shell List a l a st List

data

ai

slide-82
SLIDE 82

SWT to Swing

74

Display Shell List a l a st List

data

ai

slide-83
SLIDE 83

SWT to Swing

75

Display Shell List a l a st List

data

ai

slide-84
SLIDE 84

SWT to Swing

76

Display Shell List a l a st List

data

ai

slide-85
SLIDE 85

SWT to Swing

77

Display Shell List a l a st List

data

ai

slide-86
SLIDE 86

SWT to Swing

78

Display Shell List a l a st List

data

ai

slide-87
SLIDE 87

Non-trivial Mapping Multiplicities

slide-88
SLIDE 88

Target Multiplicities

80

Name Example

No Target

Display→ ∅

Single Target

Vector→ArrayList

Alternative Targets

Button→JButton | JCheckBox

Composite Targets

List→JList, ListModel

slide-89
SLIDE 89

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)

slide-90
SLIDE 90

Layered Adapter

slide-91
SLIDE 91

Layered Adapter

82

ScrollableJListAdapter SimpleJListAdapter

slide-92
SLIDE 92

Layered Adapter

82

ScrollableJListAdapter SimpleJListAdapter

Alternative and Composite List → (JList, ListModel)|(JList, ListModel, JScrollPane)

slide-93
SLIDE 93

Stateful Adapter

slide-94
SLIDE 94

Stateful Adapter

84

slide-95
SLIDE 95

SWT to Swing

85

Display Shell List a l a st List

data

ai

slide-96
SLIDE 96

SWT to Swing

86

Display Shell List Sel i s a l a st List

data

ai

slide-97
SLIDE 97

SWT to Swing

87

Display Shell List Sel i s a l a st i s List

data

ai

slide-98
SLIDE 98

SWT to Swing

88

Display Shell List Sel i s a l a st i s List

data

ai

slide-99
SLIDE 99

Inversion of Control

slide-100
SLIDE 100

Inverse Delegation

slide-101
SLIDE 101

SWT to Swing

91

Display Shell List Sel i s a l a st i s List

data

ai

slide-102
SLIDE 102

SWT to Swing

92

Display Shell List Sel i s a l a st i s List

data

ai

getChildren()

slide-103
SLIDE 103

SWT to Swing

93

Display Shell List Sel i s a l a st i s List

data

ai

getChildren() getComponents()

slide-104
SLIDE 104

SWT to Swing

94

Display Shell List Sel i s a l a st i s List

data

ai

getChildren() getComponents()

slide-105
SLIDE 105

SWT to Swing

95

Display Shell List Sel i s a l a st i s List

data

ai

getChildren() getComponents()

slide-106
SLIDE 106

Correspondence of Object Identities

slide-107
SLIDE 107

Wrapping Identity Map

slide-108
SLIDE 108

Wrapper Metrics

slide-109
SLIDE 109

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 ✔ ✘ ✘

slide-110
SLIDE 110

4 - Conclusion and Future Work

slide-111
SLIDE 111

Conclusion

slide-112
SLIDE 112

Conclusion

102

Challenges of OO API Migration by Wrapping in practice

slide-113
SLIDE 113

Conclusion

102

Challenges of OO API Migration by Wrapping in practice Solutions as design patterns

slide-114
SLIDE 114

Future Work

slide-115
SLIDE 115

Future Work

104

Validation of patterns in additional projects and domains

slide-116
SLIDE 116

Future Work

104

Validation of patterns in additional projects and domains DSL for API Migration

slide-117
SLIDE 117

Questions?