A Functional Pattern System for Object-Oriented Design
Table of Contents
Thesis iii
Preface v
List of Figures (90)
List of Tables (21)
Prologue 1
I Foundation 7
1 Functional programming 9
1.1 Worldview 9
1.2 Concepts 10
1.2.1 Functional decomposition 10
1.2.2 Reduction Semantics 11
1.2.3 Higher-Order Functions 12
1.2.4 Lazy evaluation 14
1.2.5 Pattern Matching 16
1.2.6 Type inference 17
1.3 Review 17
1.3.1 Pro 17
1.3.1.1 Programming Discipline 18
1.3.1.2 Concise programs 18
1.3.2 Contra 21
1.3.2.1 Functional decomposition 21
1.3.2.2 Reduction semantics 21
1.3.2.3 Deceptive Clearness 26
2 Object-orientation 29
2.1 Worldview 29
2.2 Concepts 31
2.2.1 Object-oriented decomposition 32
2.2.2 Encapsulation 32
2.2.3 Inheritance 33
2.2.4 Subtyping 34
2.2.5 Dynamic Binding 35
2.2.6 Identity 37
2.3 Review 38
2.3.1 Pro 38
2.3.1.1 Real world modeling 38
2.3.1.2 Maintainability 39
2.3.1.3 Beyond the imperative 40
2.3.2 Contra 40
2.3.2.1 Imperative heritage 41
2.3.2.2 Classes for everything 42
2.3.2.3 Inheritance for everything 42
3 Calculus comparison 45
3.1 Language comparisons 45
3.2 Opulus 46
3.3 Opulus within ?-calculus
47
3.4 ?-calculus within Opulus
48
3.5 Conclusion 51
4 Conflict & Cohabitance 55
4.1 Conflict 55
4.1.1 Oppositions 55
4.1.1.1 Semantic model 55
4.1.1.2 Decomposition 56
4.1.1.3 Evaluation56
4.1.1.4 Encapsulation56
4.1.2 Redundancy 57
4.1.2.1 Parameterization 57
4.1.2.2 Dispatch 57
4.2 Cohabitance 57
4.2.1
Subsumption 57
4.2.1.1 Pure functions 57
4.2.1.2 Dispatch 58
4.2.2
Integration 59
4.2.2.1 Evaluation 59
4.2.2.2 Closures 59
4.2.3 Synergy 59
4.2.3.1 Parameterization 60
4.2.3.2 Decomposition 64
4.3 Conclusion 68
5 Design Patterns 69
5.1 Definition 69
5.1.1 A gentle introduction 69
5.1.2 Software Patterns 72
5.2 History 74
5.3 Promise 75
5.4 Form 77
5.5 Diagram notation 80
5.5.1 Class diagram notation 80
5.5.2 Object diagram notation 80
5.5.3 Interaction diagram notation 81
II Pattern System 83
6 Catalog 85
6.1 Proto-Patterns 85
6.2 Pattern System 86
6.2.1 Function Object 86
6.2.2 Lazy Object 87
6.2.3 Value Object 87
6.2.4 Transfold 88
6.2.5 Void Value 88
6.2.6 Translator 89
6.3 Why Eiffel? 90
7 Function Object 93
7.1 Intent 93
7.2 Also Known As 93
7.3 Motivation 93
7.3.1 Problem 93
7.3.2 Solution 96
7.4 Applicability 98
7.5 Structure 100
7.6 Participants 101
7.7 Collaborations 101
7.8 Consequences 102
7.9 Implementation 105
7.10 Function Object variants
107
7.11 Known Uses 110
7.12 Related Patterns 110
7.12.1 Categorization 110
7.12.2 Collaboration 112
7.12.3 Implementation 112
8 Lazy Object 115
8.1 Intent 115
8.2 Also Known As 115
8.3 Motivation 115
8.3.1 Problem 115
8.3.2 Solution 116
8.4 Applicability 119
8.5 Structure 121
8.6 Participants 121
8.7 Collaborations 122
8.8 Consequences 122
8.9 Implementation 127
8.10 Sample Code 129
8.11 Known Uses 143
8.12 Related Patterns 144
8.12.1 Categorization 144
8.12.2 Collaboration 145
8.12.3 Implementation 145
9 Value Object 149
9.1 Intent 149
9.2 Also Known As 149
9.3 Motivation 149
9.3.1 Problem 149
9.3.2 Solution 152
9.4 Applicability 154
9.5 Structure 154
9.6 Participants 155
9.7 Collaborations 155
9.8 Consequences 155
9.9 Implementation 158
9.10 Known Uses 160
9.11 Related Patterns 160
9.11.1 Categorization 160
9.11.2 Collaboration 161
9.11.3 Implementation 162
10 Transfold 163
10.1 Intent 163
10.2 Motivation 163
10.2.1 Problem 163
10.2.2 Solution 167
10.3 Applicability 173
10.4 Structure 174
10.5 Participants 175
10.6 Collaborations 175
10.7 Consequences 176
10.8 Implementation 180
10.9 Sample Code 181
10.10 Known Uses 187
10.11 Related Patterns 187
10.11.1 Categorization 187
10.11.2 Collaboration 188
10.11.3 Implementation 188
11 Void Value 189
11.1 Intent 189
11.2 Motivation 189
11.2.1 Problem 189
11.2.2 Solution 190
11.3 Applicability 192
11.4 Structure 193
11.5 Participants 193
11.6 Collaborations 194
11.7 Consequences 194
11.8 Implementation 195
11.9 Known Uses 197
11.10 Related Patterns 197
11.10.1 Categorization 197
11.10.2 Collaboration 197
11.10.3 Implementation 198
12 Translator 199
12.1 Intent 199
12.2 Motivation 199
12.2.1 Problem 200
12.2.2 Solution 201
12.3 Applicability 202
12.4 Structure 204
12.5 Participants 205
12.6 Collaborations 206
12.7 Consequences 207
12.8 Implementation 210
12.9 Sample Code 212
12.10 Related Patterns 215
12.10.1 Categorization 215
12.10.2 Collaboration 216
12.10.3 Implementation 217
13 Collaboration 219
13.1 Example collaboration 225
III Language design 229
14 Pattern Driven Language Design 231
14.1 Introduction 231
14.2 Function Object 231
14.3 Translator 236
14.4 Transfold 237
14.5 Value Object 241
14.6 Lazy Object 243
14.7 Void Value 245
14.8 Conclusion 249
Epilogue 257
Bibliography 269
Index 299