书籍详情
JAVA设计模式(第二版 英文影印版)
作者:(美)Steven John Metsker;William C. Wake
出版社:人民邮电出版社
出版时间:2007-04-01
ISBN:9787115155696
定价:¥75.00
购买这本书可以去
内容简介
本书可以让读者在亲手实践中深刻领会并全面掌握Java软件项目中设计模式的巨大力量。本书采取学用结合的实用手册形式,带领读者应用Java的最新特性,实践23种原始模式的最佳做法。.Steve Metsker 和 Bill Wake凭借丰富的Java教学和编程经验,在讲解每一个模式时都辅以真实的Java程序、清晰的UML图表和趣味盎然的练习,使读者可以很快从理论过渡到实践――学会如何改进新的代码和重构已有代码,使其简洁、可管理且性能优良。..如果您是Java程序员,既想节省时间,又想写出更好的代码,本书中的技术、技巧、清晰的讲解、明快的示例会帮助您驾驭模式的力量,改进您所写、所设计、所维护的每一个程序。本书适合有一定基础,需要节省时间并改善代码性能的Java程序员。...
作者简介
本书提供作译者介绍Steven John Metsker 在设计模式、面向对象程序设计方法学等领域有广泛的著述,致力于研究编写结构清晰功能强大的软件,在《Java Report》、《JOOP》、《Distributed Object Computing》和《Object Magazine》等杂志上发表了多篇著作。.William C. Wake是一位自由软件顾问、指导和训练师,有二十多年的编程经验,著有《Refactoring Workbook》和《Extreme Programming Explored》等著作。...
目录
CHAPTER 1 INTRODUCTION 1
Why Patterns? 1
Why Design Patterns? 2
Why Java? 3
UML 4
Challenges 4
The Organization of This Book 5
Welcome to Oozinoz! 6
Summary 7
PART I INTERFACE PATTERNS 9
CHAPTER 2 INTRODUCING INTERFACES 11
Interfaces and Abstract Classes 11
Interfaces and Obligations 13
Summary 15
Beyond Ordinary Interfaces 16
CHAPTER 3 ADAPTER 17
Adapting to an Interface 17
Class and Object Adapters 21
Adapting Data for a Jtable 25
Identifying Adapters 30
Summary 31
CHAPTER 4 FA?ADE 33
Facades, Utilities, and Demos 33
Refactoring to FACADE 35
Summary 46
CHAPTER 5 COMPOSITE 47
An Ordinary Composite 47
Recursive Behavior in Composites 48
Composites, Trees, and Cycles 50
Composites with Cycles 56
Consequences of Cycles 60
Summary 60
CHAPTER 6 BRIDGE 63
An Ordinary Abstraction: On the Way to BRIDGE 63
From Abstraction to BRIDGE 66
Drivers as BRIDGEs 68
Database Drivers 69
Summary 71
PART II RESPONSIBILITY PATTERNS 73
CHAPTER 7 INTRODUCING RESPONSIBILITY 75
Ordinary Responsibility 75
Controlling Responsibility with Visibility 77
Summary 79
Beyond Ordinary Responsibility 79
CHAPTER 8 SINGLETON 81
SINGLETON Mechanics 81
Singletons and Threads 83
Recognizing SINGLETON 84
Summary 86
CHAPTER 9 OBSERVER 87
A Classic Example: OBSERVER in GUIs 87
Model/View/Controller 92
Maintaining an Observable Object 99
Summary 101
CHAPTER 10 MEDIATOR 103
A Classic Example: GUI Mediators 103
Mediators of Relational Integrity 108
Summary 116
CHAPTER 11 PROXY 117
A Classic Example: Image Proxies 117
Image Proxies Reconsidered 122
Remote Proxies 125
Dynamic Proxies 131
Summary 136
CHAPTER 12 CHAIN OF RESPONSIBILITY 137
An Ordinary Chain of Responsibility 137
Refactoring to CHAIN OF RESPONSIBILITY 139
Anchoring a Chain 142
CHAIN OF RESPONSIBILITY without COMPOSITE 144
Summary 144
CHAPTER 13 FLYWEIGHT 145
Immutability 145
Extracting the Immutable Part of a Flyweight 146
Sharing Flyweights 148
Summary 152
PART III CONSTRUCTION PATTERNS 153
CHAPTER 14 INTRODUCING CONSTRUCTION 155
A Few Construction Challenges 155
Summary 157
Beyond Ordinary Construction 157
CHAPTER 15 BUILDER 159
An Ordinary Builder 159
Building under Constraints 162
A Forgiving Builder 164
Summary 165
CHAPTER 16 FACTORY METHOD 167
A Classic Example: Iterators 167
Recognizing FACTORY METHOD 168
Taking Control of Which Class to Instantiate 169
FACTORY METHOD in Parallel Hierarchies 171
Summary 173
CHAPTER 17 ABSTRACT FACTORY 175
A Classic Example: GUI Kits 175
Abstract Factories and Factory Method 180
Packages and Abstract Factories 184
Summary 185
CHAPTER 18 PROTOTYPE 187
Prototypes as Factories 187
Prototyping with Clones 189
Summary 192
CHAPTER 19 MEMENTO 193
A Classic Example: Using Memento for Undo 193
Memento Durability 201
Persisting Mementos Across Sessions 201
Summary 205
PART IV OPERATION PATTERNS 207
CHAPTER 20 INTRODUCING OPERATIONS 209
Operations and Methods 209
Signatures 211
Exceptions 212
Algorithms and Polymorphism 213
Summary 214
Beyond Ordinary Operations 215
CHAPTER 21 TEMPLATE METHOD 217
A Classic Example: Sorting 217
Completing an Algorithm 221
TEMPLATE METHOD Hooks 224
Refactoring to TEMPLATE METHOD 225
Summary 228
CHAPTER 22 STATE 229
Modeling States 229
Refactoring to STATE 233
Making States Constant 238
Summary 240
CHAPTER 23 STRATEGY 241
Modeling Strategies 241
Refactoring to STRATEGY 244
Comparing STRATEGY and STATE 248
Comparing STRATEGY and TEMPLATE Method 249
Summary 250
CHAPTER 24 COMMAND 251
A Classic Example: Menu Commands 251
Using COMMAND to Supply a Service 254
COMMAND Hooks 255
COMMAND in Relation to Other Patterns 257
Summary 259
CHAPTER 25 INTERPRETER 261
An INTERPRETER Example 261
Interpreters, Languages, and Parsers 274
Summary 275
PART V EXTENSION PATTERNS 277
CHAPTER 26 INTRODUCING EXTENSIONS 279
Principles of Object-Oriented Design 279
The Liskov Substitution Principle 280
The Law of Demeter 281
Removing Code Smells 283
Beyond Ordinary Extensions 283
Summary 285
CHAPTER 27 DECORATOR 287
A Classic Example: Streams and Writers 287
Function Wrappers 295
DECORATOR in Relation to Other Patterns 303
Summary 303
CHAPTER 28 ITERATOR 305
Ordinary Iteration 305
Thread-Safe Iteration 307
Iterating over a Composite 313
Summary 324
CHAPTER 29 VISITOR 325
VISITOR Mechanics 325
An Ordinary VISITOR 327
VISITOR Cycles 333
VISITOR Risks 338
Summary 340
PART VI APPENDIXES 341
APPENDIX A DIRECTIONS 343
Get the Most from This Book 343
Understand the Classics 344
Weave Patterns into Your Code 344
Keep Learning 345
APPENDIX B SOLUTIONS 347
APPENDIX C OOZINOZ SOURCE 427
Acquiring and Using the Source 427
Building the Oozinoz Code 427
Testing the Code with JUnit 428
Finding Files Yourself 428
Summary 429
APPENDIX D UML AT A GLANCE 431
Classes 432
Class Relationships 433
Interfaces 435
Objects 436
States 437
Glossary 439
Bibliography 447
Index 449
Why Patterns? 1
Why Design Patterns? 2
Why Java? 3
UML 4
Challenges 4
The Organization of This Book 5
Welcome to Oozinoz! 6
Summary 7
PART I INTERFACE PATTERNS 9
CHAPTER 2 INTRODUCING INTERFACES 11
Interfaces and Abstract Classes 11
Interfaces and Obligations 13
Summary 15
Beyond Ordinary Interfaces 16
CHAPTER 3 ADAPTER 17
Adapting to an Interface 17
Class and Object Adapters 21
Adapting Data for a Jtable 25
Identifying Adapters 30
Summary 31
CHAPTER 4 FA?ADE 33
Facades, Utilities, and Demos 33
Refactoring to FACADE 35
Summary 46
CHAPTER 5 COMPOSITE 47
An Ordinary Composite 47
Recursive Behavior in Composites 48
Composites, Trees, and Cycles 50
Composites with Cycles 56
Consequences of Cycles 60
Summary 60
CHAPTER 6 BRIDGE 63
An Ordinary Abstraction: On the Way to BRIDGE 63
From Abstraction to BRIDGE 66
Drivers as BRIDGEs 68
Database Drivers 69
Summary 71
PART II RESPONSIBILITY PATTERNS 73
CHAPTER 7 INTRODUCING RESPONSIBILITY 75
Ordinary Responsibility 75
Controlling Responsibility with Visibility 77
Summary 79
Beyond Ordinary Responsibility 79
CHAPTER 8 SINGLETON 81
SINGLETON Mechanics 81
Singletons and Threads 83
Recognizing SINGLETON 84
Summary 86
CHAPTER 9 OBSERVER 87
A Classic Example: OBSERVER in GUIs 87
Model/View/Controller 92
Maintaining an Observable Object 99
Summary 101
CHAPTER 10 MEDIATOR 103
A Classic Example: GUI Mediators 103
Mediators of Relational Integrity 108
Summary 116
CHAPTER 11 PROXY 117
A Classic Example: Image Proxies 117
Image Proxies Reconsidered 122
Remote Proxies 125
Dynamic Proxies 131
Summary 136
CHAPTER 12 CHAIN OF RESPONSIBILITY 137
An Ordinary Chain of Responsibility 137
Refactoring to CHAIN OF RESPONSIBILITY 139
Anchoring a Chain 142
CHAIN OF RESPONSIBILITY without COMPOSITE 144
Summary 144
CHAPTER 13 FLYWEIGHT 145
Immutability 145
Extracting the Immutable Part of a Flyweight 146
Sharing Flyweights 148
Summary 152
PART III CONSTRUCTION PATTERNS 153
CHAPTER 14 INTRODUCING CONSTRUCTION 155
A Few Construction Challenges 155
Summary 157
Beyond Ordinary Construction 157
CHAPTER 15 BUILDER 159
An Ordinary Builder 159
Building under Constraints 162
A Forgiving Builder 164
Summary 165
CHAPTER 16 FACTORY METHOD 167
A Classic Example: Iterators 167
Recognizing FACTORY METHOD 168
Taking Control of Which Class to Instantiate 169
FACTORY METHOD in Parallel Hierarchies 171
Summary 173
CHAPTER 17 ABSTRACT FACTORY 175
A Classic Example: GUI Kits 175
Abstract Factories and Factory Method 180
Packages and Abstract Factories 184
Summary 185
CHAPTER 18 PROTOTYPE 187
Prototypes as Factories 187
Prototyping with Clones 189
Summary 192
CHAPTER 19 MEMENTO 193
A Classic Example: Using Memento for Undo 193
Memento Durability 201
Persisting Mementos Across Sessions 201
Summary 205
PART IV OPERATION PATTERNS 207
CHAPTER 20 INTRODUCING OPERATIONS 209
Operations and Methods 209
Signatures 211
Exceptions 212
Algorithms and Polymorphism 213
Summary 214
Beyond Ordinary Operations 215
CHAPTER 21 TEMPLATE METHOD 217
A Classic Example: Sorting 217
Completing an Algorithm 221
TEMPLATE METHOD Hooks 224
Refactoring to TEMPLATE METHOD 225
Summary 228
CHAPTER 22 STATE 229
Modeling States 229
Refactoring to STATE 233
Making States Constant 238
Summary 240
CHAPTER 23 STRATEGY 241
Modeling Strategies 241
Refactoring to STRATEGY 244
Comparing STRATEGY and STATE 248
Comparing STRATEGY and TEMPLATE Method 249
Summary 250
CHAPTER 24 COMMAND 251
A Classic Example: Menu Commands 251
Using COMMAND to Supply a Service 254
COMMAND Hooks 255
COMMAND in Relation to Other Patterns 257
Summary 259
CHAPTER 25 INTERPRETER 261
An INTERPRETER Example 261
Interpreters, Languages, and Parsers 274
Summary 275
PART V EXTENSION PATTERNS 277
CHAPTER 26 INTRODUCING EXTENSIONS 279
Principles of Object-Oriented Design 279
The Liskov Substitution Principle 280
The Law of Demeter 281
Removing Code Smells 283
Beyond Ordinary Extensions 283
Summary 285
CHAPTER 27 DECORATOR 287
A Classic Example: Streams and Writers 287
Function Wrappers 295
DECORATOR in Relation to Other Patterns 303
Summary 303
CHAPTER 28 ITERATOR 305
Ordinary Iteration 305
Thread-Safe Iteration 307
Iterating over a Composite 313
Summary 324
CHAPTER 29 VISITOR 325
VISITOR Mechanics 325
An Ordinary VISITOR 327
VISITOR Cycles 333
VISITOR Risks 338
Summary 340
PART VI APPENDIXES 341
APPENDIX A DIRECTIONS 343
Get the Most from This Book 343
Understand the Classics 344
Weave Patterns into Your Code 344
Keep Learning 345
APPENDIX B SOLUTIONS 347
APPENDIX C OOZINOZ SOURCE 427
Acquiring and Using the Source 427
Building the Oozinoz Code 427
Testing the Code with JUnit 428
Finding Files Yourself 428
Summary 429
APPENDIX D UML AT A GLANCE 431
Classes 432
Class Relationships 433
Interfaces 435
Objects 436
States 437
Glossary 439
Bibliography 447
Index 449
猜您喜欢