معرفی کتاب «Design Patterns in Java(TM) (2nd Edition) (Software Patterns Series)» نوشتهٔ Steven John Metsker, William C. Wake، منتشرشده توسط نشر Addison-Wesley Professional در سال 2006. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Design Patterns in JavaTM gives you the hands-on practice and deep insight you need to fully leverage the significant power of design patterns in any Java software project. The perfect complement to the classic Design Patterns, this learn-by-doing workbook applies the latest Java features and best practices to all of the original 23 patterns identified in that groundbreaking text.Drawing on their extensive experience as Java instructors and programmers, Steve Metsker and Bill Wake illuminate each pattern with real Java programs, clear UML diagrams, and compelling exercises. You'll move quickly from theory to application—learning how to improve new code and refactor existing code for simplicity, manageability, and performance. Coverage includesUsing Adapter to provide consistent interfaces to clients Using Facade to simplify the use of reusable toolkits Understanding the role of Bridge in Java database connectivityThe Observer pattern, Model-View-Controller, and GUI behaviorJava Remote Method Invocation (RMI) and the Proxy patternStreamlining designs using the Chain of Responsibility patternUsing patterns to go beyond Java's built-in constructor features Implementing Undo capabilities with Memento Using the State pattern to manage state more cleanly and simplyOptimizing existing codebases with extension patternsProviding thread-safe iteration with the Iterator patternUsing Visitor to define new operations without changing hierarchy classesIf you're a Java programmer wanting to save time while writing better code, this book's techniques, tips, and clear explanations and examples will help you harness the power of patterns to improve every program you write, design, or maintain.All source code is available for download at http://www.oozinoz.com. Contents......Page 8 Preface......Page 14 Why Patterns?......Page 16 Why Design Patterns?......Page 17 Why Java?......Page 18 Challenges......Page 19 The Organization of This Book......Page 20 Welcome to Oozinoz!......Page 21 Summary......Page 22 PART I: INTERFACE PATTERNS......Page 24 Interfaces and Abstract Classes......Page 26 Interfaces and Obligations......Page 28 Summary......Page 30 Beyond Ordinary Interfaces......Page 31 Adapting to an Interface......Page 32 Class and Object Adapters......Page 36 Adapting Data for a JTable......Page 40 Identifying Adapters......Page 45 Summary......Page 46 Facades, Utilities, and Demos......Page 48 Refactoring to FACADE......Page 50 Summary......Page 61 An Ordinary Composite......Page 62 Recursive Behavior in Composites......Page 63 Composites, Trees, and Cycles......Page 65 Composites with Cycles......Page 71 Summary......Page 75 An Ordinary Abstraction: On the Way to BRIDGE......Page 78 From Abstraction to BRIDGE......Page 81 Drivers as BRIDGES......Page 83 Database Drivers......Page 84 Summary......Page 86 PART II: RESPONSIBILITY PATTERNS......Page 88 Ordinary Responsibility......Page 90 Controlling Responsibility with Visibility......Page 92 Beyond Ordinary Responsibility......Page 94 SINGLETON Mechanics......Page 96 Singletons and Threads......Page 98 Recognizing SINGLETON......Page 99 Summary......Page 101 A Classic Example: OBSERVER in GUIs......Page 102 Model/View/Controller......Page 107 Maintaining an Observable Object......Page 114 Summary......Page 116 A Classic Example: GUI Mediators......Page 118 Mediators of Relational Integrity......Page 123 Summary......Page 131 A Classic Example: Image Proxies......Page 132 Image Proxies Reconsidered......Page 137 Remote Proxies......Page 140 Dynamic Proxies......Page 146 Summary......Page 151 An Ordinary Chain of Responsibility......Page 152 Refactoring to CHAIN OF RESPONSIBILITY......Page 154 Anchoring a Chain......Page 157 Summary......Page 159 Immutability......Page 160 Extracting the Immutable Part of a Flyweight......Page 161 Sharing Flyweights......Page 163 Summary......Page 167 PART III: CONSTRUCTION PATTERNS......Page 168 A Few Construction Challenges......Page 170 Beyond Ordinary Construction......Page 172 An Ordinary Builder......Page 174 Building under Constraints......Page 177 A Forgiving Builder......Page 179 Summary......Page 180 A Classic Example: Iterators......Page 182 Recognizing FACTORY METHOD......Page 183 Taking Control of Which Class to Instantiate......Page 184 FACTORY METHOD in Parallel Hierarchies......Page 186 Summary......Page 188 A Classic Example: GUI Kits......Page 190 Abstract Factories and Factory Method......Page 195 Packages and Abstract Factories......Page 199 Summary......Page 200 Prototypes as Factories......Page 202 Prototyping with Clones......Page 204 Summary......Page 207 A Classic Example: Using Memento for Undo......Page 208 Persisting Mementos Across Sessions......Page 216 Summary......Page 220 PART IV: OPERATION PATTERNS......Page 222 Operations and Methods......Page 224 Signatures......Page 226 Exceptions......Page 227 Algorithms and Polymorphism......Page 228 Summary......Page 229 Beyond Ordinary Operations......Page 230 A Classic Example: Sorting......Page 232 Completing an Algorithm......Page 236 TEMPLATE METHOD Hooks......Page 239 Refactoring to TEMPLATE METHOD......Page 240 Summary......Page 243 Modeling States......Page 244 Refactoring to STATE......Page 248 Making States Constant......Page 253 Summary......Page 255 Modeling Strategies......Page 256 Refactoring to STRATEGY......Page 259 Comparing STRATEGY and STATE......Page 263 Comparing STRATEGY and TEMPLATE Method......Page 264 Summary......Page 265 A Classic Example: Menu Commands......Page 266 Using COMMAND to Supply a Service......Page 269 COMMAND Hooks......Page 270 COMMAND in Relation to Other Patterns......Page 272 Summary......Page 274 An INTERPRETER Example......Page 276 Interpreters, Languages, and Parsers......Page 289 Summary......Page 290 PART V: EXTENSION PATTERNS......Page 292 Principles of Object-Oriented Design......Page 294 The Liskov Substitution Principle......Page 295 The Law of Demeter......Page 296 Beyond Ordinary Extensions......Page 298 Summary......Page 300 A Classic Example: Streams and Writers......Page 302 Function Wrappers......Page 310 Summary......Page 318 Ordinary Iteration......Page 320 Thread-Safe Iteration......Page 322 Iterating over a Composite......Page 328 Summary......Page 339 VISITOR Mechanics......Page 340 An Ordinary VISITOR......Page 342 VISITOR Cycles......Page 348 VISITOR Risks......Page 353 Summary......Page 355 PART VI: APPENDIXES......Page 356 Get the Most from This Book......Page 358 Weave Patterns into Your Code......Page 359 Keep Learning......Page 360 APPENDIX B: SOLUTIONS......Page 362 Building the Oozinoz Code......Page 442 Finding Files Yourself......Page 443 Summary......Page 444 APPENDIX D: UML AT A GLANCE......Page 446 Classes......Page 447 Class Relationships......Page 448 Interfaces......Page 450 Objects......Page 451 States......Page 452 C......Page 454 E......Page 455 I......Page 456 M......Page 457 P......Page 458 S......Page 459 X......Page 460 Bibliography......Page 462 A......Page 464 C......Page 465 D......Page 467 G......Page 468 I......Page 469 M......Page 470 O......Page 471 P......Page 472 R......Page 473 S......Page 474 T......Page 475 X......Page 476 Contents 8 Preface 14 CHAPTER 1 INTRODUCTION 16 Why Patterns? 16 Why Design Patterns? 17 Why Java? 18 UML 19 Challenges 19 The Organization of This Book 20 Welcome to Oozinoz! 21 Summary 22 PART I: INTERFACE PATTERNS 24 CHAPTER 2 INTRODUCING INTERFACES 26 Interfaces and Abstract Classes 26 Interfaces and Obligations 28 Summary 30 Beyond Ordinary Interfaces 31 CHAPTER 3 ADAPTER 32 Adapting to an Interface 32 Class and Object Adapters 36 Adapting Data for a JTable 40 Identifying Adapters 45 Summary 46 CHAPTER 4 FACADE 48 Facades, Utilities, and Demos 48 Refactoring to FACADE 50 Summary 61 CHAPTER 5 COMPOSITE 62 An Ordinary Composite 62 Recursive Behavior in Composites 63 Composites, Trees, and Cycles 65 Composites with Cycles 71 Consequences of Cycles 75 Summary 75 CHAPTER 6 BRIDGE 78 An Ordinary Abstraction: On the Way to BRIDGE 78 From Abstraction to BRIDGE 81 Drivers as BRIDGES 83 Database Drivers 84 Summary 86 PART II: RESPONSIBILITY PATTERNS 88 CHAPTER 7 INTRODUCING RESPONSIBILITY 90 Ordinary Responsibility 90 Controlling Responsibility with Visibility 92 Summary 94 Beyond Ordinary Responsibility 94 CHAPTER 8 SINGLETON 96 SINGLETON Mechanics 96 Singletons and Threads 98 Recognizing SINGLETON 99 Summary 101 CHAPTER 9 OBSERVER 102 A Classic Example: OBSERVER in GUIs 102 Model/View/Controller 107 Maintaining an Observable Object 114 Summary 116 CHAPTER 10 MEDIATOR 118 A Classic Example: GUI Mediators 118 Mediators of Relational Integrity 123 Summary 131 CHAPTER 11 PROXY 132 A Classic Example: Image Proxies 132 Image Proxies Reconsidered 137 Remote Proxies 140 Dynamic Proxies 146 Summary 151 CHAPTER 12 CHAIN OF RESPONSIBILITY 152 An Ordinary Chain of Responsibility 152 Refactoring to CHAIN OF RESPONSIBILITY 154 Anchoring a Chain 157 CHAIN OF RESPONSIBILITY without COMPOSITE 159 Summary 159 CHAPTER 13 FLYWEIGHT 160 Immutability 160 Extracting the Immutable Part of a Flyweight 161 Sharing Flyweights 163 Summary 167 PART III: CONSTRUCTION PATTERNS 168 CHAPTER 14 INTRODUCING CONSTRUCTION 170 A Few Construction Challenges 170 Summary 172 Beyond Ordinary Construction 172 CHAPTER 15 BUILDER 174 An Ordinary Builder 174 Building under Constraints 177 A Forgiving Builder 179 Summary 180 CHAPTER 16 FACTORY METHOD 182 A Classic Example: Iterators 182 Recognizing FACTORY METHOD 183 Taking Control of Which Class to Instantiate 184 FACTORY METHOD in Parallel Hierarchies 186 Summary 188 CHAPTER 17 ABSTRACT FACTORY 190 A Classic Example: GUI Kits 190 Abstract Factories and Factory Method 195 Packages and Abstract Factories 199 Summary 200 CHAPTER 18 PROTOTYPE 202 Prototypes as Factories 202 Prototyping with Clones 204 Summary 207 CHAPTER 19 MEMENTO 208 A Classic Example: Using Memento for Undo 208 Memento Durability 216 Persisting Mementos Across Sessions 216 Summary 220 PART IV: OPERATION PATTERNS 222 CHAPTER 20 INTRODUCING OPERATIONS 224 Operations and Methods 224 Signatures 226 Exceptions 227 Algorithms and Polymorphism 228 Summary 229 Beyond Ordinary Operations 230 CHAPTER 21 TEMPLATE METHOD 232 A Classic Example: Sorting 232 Completing an Algorithm 236 TEMPLATE METHOD Hooks 239 Refactoring to TEMPLATE METHOD 240 Summary 243 CHAPTER 22 STATE 244 Modeling States 244 Refactoring to STATE 248 Making States Constant 253 Summary 255 CHAPTER 23 STRATEGY 256 Modeling Strategies 256 Refactoring to STRATEGY 259 Comparing STRATEGY and STATE 263 Comparing STRATEGY and TEMPLATE Method 264 Summary 265 CHAPTER 24 COMMAND 266 A Classic Example: Menu Commands 266 Using COMMAND to Supply a Service 269 COMMAND Hooks 270 COMMAND in Relation to Other Patterns 272 Summary 274 CHAPTER 25 INTERPRETER 276 An INTERPRETER Example 276 Interpreters, Languages, and Parsers 289 Summary 290 PART V: EXTENSION PATTERNS 292 CHAPTER 26 INTRODUCING EXTENSIONS 294 Principles of Object-Oriented Design 294 The Liskov Substitution Principle 295 The Law of Demeter 296 Removing Code Smells 298 Beyond Ordinary Extensions 298 Summary 300 CHAPTER 27 DECORATOR 302 A Classic Example: Streams and Writers 302 Function Wrappers 310 DECORATOR in Relation to Other Patterns 318 Summary 318 CHAPTER 28 ITERATOR 320 Ordinary Iteration 320 Thread-Safe Iteration 322 Iterating over a Composite 328 Summary 339 CHAPTER 29 VISITOR 340 VISITOR Mechanics 340 An Ordinary VISITOR 342 VISITOR Cycles 348 VISITOR Risks 353 Summary 355 PART VI: APPENDIXES 356 APPENDIX A: DIRECTIONS 358 Get the Most from This Book 358 Understand the Classics 359 Weave Patterns into Your Code 359 Keep Learning 360 APPENDIX B: SOLUTIONS 362 APPENDIX C: OOZINOZ SOURCE 442 Acquiring and Using the Source 442 Building the Oozinoz Code 442 Testing the Code with JUnit 443 Finding Files Yourself 443 Summary 444 APPENDIX D: UML AT A GLANCE 446 Classes 447 Class Relationships 448 Interfaces 450 Objects 451 States 452 Glossary 454 A 454 B 454 C 454 D 455 E 455 G 456 H 456 I 456 J 457 K 457 L 457 M 457 N 458 O 458 P 458 R 459 S 459 T 460 U 460 W 460 X 460 Bibliography 462 Index 464 A 464 B 465 C 465 D 467 E 468 F 468 G 468 H 469 I 469 J 470 K 470 L 470 M 470 N 471 O 471 P 472 R 473 S 474 T 475 U 476 V 476 W 476 X 476
design Patterns In Java™ Gives You The Hands-on Practice And Deep Insight You Need To Fully Leverage The Significant Power Of Design Patterns In Any Java Software Project. The Perfect Complement To The Classic Design Patterns, This Learn-by-doing Workbook Applies The Latest Java Features And Best Practices To All Of The Original 23 Patterns Identified In That Groundbreaking Text.
drawing On Their Extensive Experience As Java Instructors And Programmers, Steve Metsker And Bill Wake Illuminate Each Pattern With Real Java Programs, Clear Uml Diagrams, And Compelling Exercises. You'll Move Quickly From Theory To Application—learning How To Improve New Code And Refactor Existing Code For Simplicity, Manageability, And Performance.
coverage Includes
- using Adapter To Provide Consistent Interfaces To Clients
- using Facade To Simplify The Use Of Reusable Toolkits
- understanding The Role Of Bridge In Java Database Connectivity
- the Observer Pattern, Model-view-controller, And Gui Behavior
- java Remote Method Invocation (rmi) And The Proxy Pattern
- streamlining Designs Using The Chain Of Responsibility Pattern
- using Patterns To Go Beyond Java's Built-in Constructor Features
- implementing Undo Capabilities With Memento
- using The State Pattern To Manage State More Cleanly And Simply
- optimizing Existing Codebases With Extension Patterns
- providing Thread-safe Iteration With The Iterator Pattern
- using Visitor To Define New Operations Without Changing Hierarchy Classes
if You're A Java Programmer Wanting To Save Time Whilewriting Better Code, This Book's Techniques, Tips, And Clear Explanations And Examples Will Help You Harness The Power Of Patterns To Improve Every Program You Write, Design, Or Maintain.
all Source Code Is Available For Download At Http://www.oozinoz.com.
Design Patterns in JavaTM gives you the hands-on practice and deep insight you need to fully leverage the significant power of design patterns in any Java software project. The perfect complement to the classic Design Patterns, this learn-by-doing workbook applies the latest Java features and best practices to all of the original 23 patterns identified in that groundbreaking text. Drawing on their extensive experience as Java instructors and programmers, Steve Metsker and Bill Wake illuminate each pattern with real Java programs, clear UML diagrams, and compelling exercises. You'll move quickly from theory to application–learning how to improve new code and refactor existing code for simplicity, manageability, and performance. Coverage includes Using Adapter to provide consistent interfaces to clients Using Facade to simplify the use of reusable toolkits Understanding the role of Bridge in Java database connectivity The Observer pattern, Model-View-Controller, and GUI behavior Java Remote Method Invocation (RMI) and the Proxy pattern Streamlining designs using the Chain of Responsibility pattern Using patterns to go beyond Java's built-in constructor features Implementing Undo capabilities with Memento Using the State pattern to manage state more cleanly and simply Optimizing existing codebases with extension patterns Providing thread-safe iteration with the Iterator pattern Using Visitor to define new operations without changing hierarchy classes If you're a Java programmer wanting to save time while writing better code, this book's techniques, tips, and clear explanations and examples will help you harness the power of patterns to improve every program you write, design, or maintain. All source code is available for download at http://www.oozinoz.com.