وبلاگ بلیان

Design Patterns Java(TM) Workbook (Software Patterns Series)

معرفی کتاب «Design Patterns Java(TM) Workbook (Software Patterns Series)» نوشتهٔ Steven John Metsker، منتشرشده توسط نشر Addison-Wesley Professional در سال 2002. این کتاب در 4 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «Design Patterns Java(TM) Workbook (Software Patterns Series)» در دستهٔ بدون دسته‌بندی قرار دارد.

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

Praise for Design Patterns JavaTM Workbook

“An excellent book... I’m incredibly impressed with how readable it is. I understood every single chapter, and I think any reader with any Java familiarity would. This book is going to be required reading in a lot of places, including my office.”

     —Joshua Engel

“Provides a new, more Java-literate way to understand the 23 GoF patterns.”

     —Bob Hanmer

“This book translates Design Patterns into what Java programmers need to know. It is full of short, engaging programming and design problems with solutions—making it easy for programmers to work through solutions and really make patterns ‘stick.’”

     —Rebecca Wirfs-Brock

“This is one exciting book. It’s approachable, readable, interesting, instructive, and just plain valuable. It’ll eclipse all other books purporting to teach people the GoF patterns in Java—and perhaps any other language.”

     —John Vlissides

Java programmers, you now have the resource you need to harness the considerable power of design patterns. This unique book presents examples, exercises, and challenges that will help you apply design pattern theory to real-world problems. Steve Metsker's learn-by-doing approach helps you enhance your practical skills and build the confidence you need to use design patterns effectively in mission-critical applications.

Design Patterns JavaTM Workbook features the twenty-three foundational design patterns introduced in the classic book Design Patterns (Addison-Wesley, 1995). In this new, hands-on workbook, the patterns are organized into five major categories: interfaces, responsibility, construction, operations, and extensions. Each category begins with a chapter that reviews and challenges your ability to apply facilities built into Java. These introductory sections are followed by chapters that explain a particular pattern in detail, demonstrate the pattern in use with UML diagrams and Java code, and provide programming problems for you to solve.

With this book you will build expertise in important areas such as:

  • Adapting domain data to Swing components
  • Creating a FACADE for Swing
  • Handling recursion in composites
  • Understanding the role of BRIDGE in Java database connectivity
  • Making the connection between Model/View/Controller and OBSERVER
  • Maintaining relational integrity with a mediator
  • Using proxies to communicate between computers
  • Letting a service provider decide which class to instantiate
  • Supporting undo operations with MEMENTO
  • Prototyping with clones
  • Using COMMAND to supply a service
  • Developing thread-safe iterators
  • Extending classes with DECORATOR and VISITOR

Solutions to the design pattern challenges appear in the back of the book, so you can compare your own work to expert approaches. A brief guide to UML explains the modeling notation, and an accompanying Web site provides all the code examples from the book.

Through the instruction and exercises offered in Design Patterns JavaTM Workbook , you can fully understand the role of design patterns in Java application development, and enhance your ability to put design patterns to work.

Praise for Design Patterns Java Workbook "An excellent book... I'm incredibly impressed with how readable it is. I understood every single chapter, and I think any reader with any Java familiarity would. This book is going to be required reading in a lot of places, including my office." - Joshua Engel "Provides a new, more Java-literate way to understand the 23 GoF patterns." - Bob Hanmer "This book translates Design Patterns into what Java programmers need to know. It is full of short, engaging programming and design problems with solutions - making it easy for programmers to work through solutions and really make patterns 'stick.'" - Rebecca Wirfs-Brock "This is one exciting book. It's approachable, readable, interesting, instructive, and just plain valuable. It'll eclipse all other books purporting to teach people the GoF patterns in Java - and perhaps any other language." - John Vlissides Java programmers, you now have the resource you need to harness the considerable power of design patterns. This unique book presents examples, exercises, and challenges that will help you apply design pattern theory to real-world problems. Steve Metsker's learn-by-doing approach helps you enhance your practical skills and build the confidence you need to use design patterns effectively in mission-critical applications. Design Patterns Java Workbook features the twenty-three foundational design patterns introduced in the classic book Design Patterns (Addison-Wesley, 1995). In this new, hands-on workbook, the patterns are organized into five major categories: interfaces, responsibility, construction, operations, and extensions. Each category begins with a chapter that reviews and challenges your ability to apply facilities built into Java. These introductory sections are followed by chapters that explain a particular pattern in detail, demonstrate the pattern in use with UML diagrams and Java code, and provide programming problems for you to solve. With this book you will build expertise in important areas such as: Adapting domain data to Swing components Creating a FACADE for Swing Handling recursion in composites Understanding the role of BRIDGE in Java database connectivity Making the connection between Model/View/Controller and OBSERVER Maintaining relational integrity with a mediator Using proxies to communicate between computers Letting a service provider decide which class to instantiate Supporting undo operations with MEMENTO Workbook approach deepens your understanding, builds your confidence, and strengthens your skills. Covers all five categories of design pattern intent: interfaces, responsibility, construction, operations, and extensions. This new workbook complements the classic Design Patterns, giving Java developers hands-on experience in transforming pattern concepts into working designs and code. Steven John Metsker presents nearly 90 practical pattern exercises, encompassing all 23 patterns first introduced in Design Patterns, and others that have since been identified. Metsker organizes Java design patterns by five categories of "intent": interfaces, responsibility, construction, operations, and extensions. Each section of the book focuses on one category, identifying the relevant challenges facing Java developers, and showing how specific patterns can be used to solve problems that recur in Java development and cannot easily be solved without their use. A Solutions chapter provides Metsker's detailed solutions to each problem, including -- where necessary -- UML diagrams. For all Java developers who want to use patterns to impro ve their software. Includes CDROM This workbook approach deepens understanding, builds confidence, and strengthens readersU skills. It covers all five categories of design pattern intent: interfaces, responsibility, construction, operations, and extensions. Presents examples, exercises, and challenges that enable you to grapple with alternative approaches and discover practical subtleties in applying design pattern theory to realistic problems. Softcover. CD-ROM included.
دانلود کتاب Design Patterns Java(TM) Workbook (Software Patterns Series)