Design Patterns Java(TM) Workbook

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The intent of the author is good, i.e., providing a workshop for people who are learning GoF design patterns. But result is disappointing. First of all, design pattern would lose most of its values (or at least it is hard to appreciate its value) if there is no design context and forces that constrain or influence the solution proposed by the pattern. The context and resolution of these forces will let the reader/designer the see the value of how a design pattern fits in and balances the forces and maintains a level of flexibility. However, each chapter of the book provides little context for the design challenges. Secondly, I don't understand why the author picks fireworks industry as the background for all the examples in the book, it is an area that most people are not familiar with. I know design patterns are not domain specific and can be applied broadly, but knowing the background of the industry in the examples is definitely helpful for readers. And all those examples are very boring, and sometime ridiculous. Thirdly, the author tries to provide some pattern refactoring examples, but does a lousy job compared with Joshua Kerievsky, the author of "Refactor to Patterns", who provides clear steps to refactor from an existing causal (bad) design to a pattern. Particularly, what are the problems of the existing design and how a design pattern will solve those problems. Overall, I am sorry to say that the author's mission failed terribly for such a good will.

Author(s): Steven John Metsker
Publisher: Addison-Wesley Professional
Year: 2002

Language: English
Commentary: +OCR
Pages: 400

Cover......Page 1
Table of Contents......Page 7
Foreword......Page 14
Preface......Page 15
Why Design Patterns?......Page 17
Why Java?......Page 19
Why a Workbook?......Page 20
The Organization of This Book......Page 21
Summary......Page 22
Part I: Interface Patterns......Page 23
Ordinary Interfaces......Page 24
Interfaces and Obligations......Page 25
Placing Constants in Interfaces......Page 26
Beyond Ordinary Interfaces......Page 29
Adapting in the Presence of Foresight......Page 30
Class and Object Adapters......Page 34
Unforeseen Adaptation......Page 40
Recognizing Adapter......Page 41
Summary......Page 42
Refactoring to Facade......Page 44
Facades, Utilities, and Demos......Page 54
Summary......Page 56
An Ordinary Composite......Page 57
Recursive Behavior in Composites......Page 58
Trees in Graph Theory......Page 59
Composites with Cycles......Page 63
Summary......Page 68
A Classic Example of Bridge: Drivers......Page 69
Refactoring to Bridge......Page 73
A Bridge Using the List Interface......Page 76
Summary......Page 77
Part II: Responsibility Patterns......Page 78
Ordinary Responsibility......Page 79
Controlling Responsibility with Visibility......Page 81
Beyond Ordinary Responsibility......Page 83
Singleton Mechanics......Page 85
Singletons and Threads......Page 86
Recognizing Singleton......Page 87
Summary......Page 88
A Classic Example: Observer in Swing......Page 89
Model/ View/ Controller......Page 92
Maintaining an Observable Object......Page 96
Summary......Page 98
A Classic Example: GUI Mediators......Page 100
Relational Integrity Mediators......Page 104
Summary......Page 108
A Classic Example: Image Proxies......Page 109
Image Proxies Reconsidered......Page 114
Remote Proxies......Page 115
Summary......Page 121
Refactoring to Chain of Responsibility......Page 122
Anchoring a Chain......Page 125
Summary......Page 127
Immutability......Page 128
Extracting the Immutable Part of a Flyweight......Page 129
Sharing Flyweights......Page 131
Summary......Page 134
Part III: Construction Patterns......Page 135
Superclass Collaboration......Page 136
Collaboration within a Class......Page 137
Beyond Ordinary Construction......Page 139
Building from a Parser......Page 140
Building under Constraints......Page 141
Summary......Page 144
Recognizing Factory Method......Page 145
A Classic Example of Factory Method: Iterators......Page 146
Taking Control of Which Class to Instantiate......Page 147
Factory Method in Parallel Hierarchies......Page 149
Summary......Page 151
Abstract Factories for Families of Objects......Page 153
Packages and Abstract Factories......Page 156
Abstract Factories for Look- and- Feel......Page 157
Summary......Page 158
Prototypes as Factories......Page 159
Prototyping with Clones......Page 160
Using Object.clone()......Page 162
Summary......Page 166
Applying Memento......Page 167
Persisting Mementos across Sessions......Page 170
Using Strings as Mementos......Page 172
Summary......Page 173
Part IV: Operation Patterns......Page 174
Operations, Methods, and Algorithms......Page 175
The Mechanics of Methods......Page 177
Exceptions in Methods......Page 178
Beyond Ordinary Operations......Page 180
A Classic Example of Template Method: Sorting......Page 182
Completing an Algorithm......Page 184
Template Method Hooks......Page 187
Refactoring to Template Method......Page 188
Summary......Page 190
Modeling States......Page 191
Refactoring to State......Page 194
Making States Constant......Page 198
Summary......Page 199
Modeling Strategies......Page 200
Refactoring to Strategy......Page 202
Comparing Strategy and State......Page 206
Summary......Page 207
A Classic Example: Menu Commands......Page 208
Using Command to Supply a Service......Page 210
Command in Relation to Other Patterns......Page 211
Summary......Page 214
An Interpreter Example......Page 215
Interpreters, Languages, and Parsers......Page 223
Summary......Page 224
Part V: Extension Patterns......Page 226
Reuse as an Alternative to Extension......Page 227
Extending by Subclassing......Page 232
The Liskov Substitution Principle......Page 233
Extending by Delegating......Page 235
Beyond Ordinary Extension......Page 237
A Classic Example of Decorator: Streams......Page 239
Function Decorators......Page 247
Decorating without Decorator......Page 257
Summary......Page 259
Type-Safe Collections......Page 260
Iterating Over a Composite......Page 264
Thread- Safe Iterators......Page 273
Summary......Page 277
Supporting Visitor......Page 278
Extending with Visitor......Page 279
Visitor Cycles......Page 286
Visitor Controversy......Page 289
Summary......Page 290
Part VI: Appendixes......Page 291
Understand the Classics......Page 292
Keep Learning......Page 293
Appendix B. Solutions......Page 295
Introducing Interfaces ( Chapter 2)......Page 297
Adapter ( Chapter 3)......Page 301
Facade ( Chapter 4)......Page 304
Composite ( Chapter 5)......Page 306
Bridge ( Chapter 6)......Page 309
Introducing Responsibility ( Chapter 7)......Page 313
Singleton ( Chapter 8)......Page 315
Observer ( Chapter 9)......Page 317
Mediator ( Chapter 10)......Page 321
Proxy ( Chapter 11)......Page 325
Chain of Responsibility ( Chapter 12)......Page 327
Flyweight ( Chapter 13)......Page 330
Introducing Construction ( Chapter 14)......Page 333
Builder ( Chapter 15)......Page 335
Factory Method ( Chapter 16)......Page 337
Abstract Factory ( Chapter 17)......Page 341
Prototype ( Chapter 18)......Page 345
Memento ( Chapter 19)......Page 348
Introducing Operations ( Chapter 20)......Page 350
Template Method ( Chapter 21)......Page 351
State ( Chapter 22)......Page 353
Strategy ( Chapter 23)......Page 356
Command ( Chapter 24)......Page 358
Interpreter ( Chapter 25)......Page 361
Introducing Extensions ( Chapter 26)......Page 363
Decorator ( Chapter 27)......Page 367
Iterator ( Chapter 28)......Page 370
Visitor ( Chapter 29)......Page 374
Classes......Page 377
Class Relationships......Page 378
Objects......Page 380
States......Page 381
Glossary......Page 383
Bibliography......Page 398