Design Patterns in Java (Software Patterns Series)

Design Patterns in Java (Software Patterns Series)

  • ただいまウェブストアではご注文を受け付けておりません。 ⇒古書を探す
  • 製本 Hardcover:ハードカバー版/ページ数 461 p.
  • 言語 ENG
  • 商品コード 9780321333025
  • DDC分類 005.133

Full Description


Design Patterns in Java (TM) 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 clientsUsing Facade to simplify the use of reusable toolkitsUnderstanding 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 featuresImplementing 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

Preface xiiiChapter 1 Introduction 1Why Patterns? 1Why Design Patterns? 2Why Java? 3UML 4Challenges 4The Organization of This Book 5Welcome to Oozinoz! 6Summary 7Part I Interface Patterns 9Chapter 2 Introducing Interfaces 11Interfaces and Abstract Classes 11Interfaces and Obligations 13Summary 15Beyond Ordinary Interfaces 16Chapter 3 Adapter 17Adapting to an Interface 17Class and Object Adapters 21Adapting Data for a JTable 25Identifying Adapters 30Summary 31Chapter 4 Facade 33Facades, Utilities, and Demos 33Refactoring to Facade 35Summary 46Chapter 5 Composite 47An Ordinary Composite 47Recursive Behavior in Composites 48Composites, Trees, and Cycles 50Composites with Cycles 56Consequences of Cycles 60Summary 60Chapter 6 Bridge 63An Ordinary Abstraction: On the Way to Bridge 63From Abstraction to Bridge 66Drivers as Bridges 68Database Drivers 69Summary 71Part II Responsibility Patterns 73Chapter 7 Introducing Responsibility 75Ordinary Responsibility 75Controlling Responsibility with Visibility 77Summary 79Beyond Ordinary Responsibility 79Chapter 8 Singleton 81Singleton Mechanics 81Singletons and Thread 83Recognizing Singleton 84Summary 86Chapter 9 Observer 87A Classic Example: Observer in GUIs 87Model/View/Controller 92Maintaining an Observable Object 99Summary 101Chapter 10 Mediator 103A Classic Example: GUI Mediators 103Mediators of Relational Integrity 108Summary 116Chapter 11 Proxy 117A Classic Example: Image Proxies 117Image Proxies Reconsidered 122Remote Proxies 125Dynamic Proxies 131Summary 136Chapter 12 Chain of Responsibility 137An Ordinary Chain of Responsibility 137Refactoring to Chain of Responsibility 139Anchoring a Chain 142Chain of Responsibility without Composite 144Summary 144Chapter 13 Flyweight 145Immutability 145Extracting the Immutable Part of a Flyweight 146Sharing Flyweights 148Summary 152Part III Construction Patterns 153Chapter 14 Introducing Construction 155A Few Construction Challenges 155Summary 157Beyond Ordinary Construction 157Chapter 15 Builder 159An Ordinary Builder 159Building under Constraints 162A Forgiving Builder 164Summary 165Chapter 16 Factory Method 167A Classic Example: Iterators 167Recognizing Factory Method 168Taking Control of Which Class to Instantiate 169Factory Method in Parallel Hierarchies 171Summary 173Chapter 17 Abstract Factory 175A Classic Example: GUI Kits 175Abstract Factories and Factory Method 180Packages and Abstract Factories 184Summary 185Chapter 18 Prototype 187Prototypes as Factories 187Prototyping with Clones 189Summary 192Chapter 19 Memento 193A Classic Example: Using Memento for Undo 193Memento Durability 201Persisting Mementos Across Sessions 201Summary 205Part IV Operation Patterns 207Chapter 20 Introducing Operations 209Operations and Methods 209Signatures 211Exceptions 212Algorithms and Polymorphism 213Summary 214Beyond Ordinary Operations 215Chapter 21 Template Method 217A Classic Example: Sorting 217Completing an Algorithm 221Template Method Hooks 224Refactoring to Template Method 225Summary 228Chapter 22 State 229Modeling States 229Refactoring to State 233Making States Constant 238Summary 240Chapter 23 Strategy 241Modeling Strategies 241Refactoring to Strategy 244Comparing Strategy and State 248Comparing Strategy and Template Method 249Summary 250Chapter 24 Command 251A Classic Example: Menu Commands 251Using Command to Supply a Service 254Command Hooks 255Command in Relation to Other Patterns 257Summary 259Chapter 25 Interpreter 261An Interpreter Example 261Interpreters, Languages, and Parsers 274Summary 275Part V Extension Patterns 277Chapter 26 Introducing Extensions 279Principles of Object-Oriented Design 279The Liskov Substitution Principle 280The Law of Demeter 281Removing Code Smells 283Beyond Ordinary Extensions 283Summary 285Chapter 27 Decorator 287A Classic Example: Streams and Writers 287Function Wrappers 295Decorator in Relation to Other Patterns 303Summary 303Chapter 28 Iterator 305Ordinary Iteration 305Thread-Safe Iteration 307Iterating over a Composite 313Summary 324Chapter 29 Visitor 325Visitor Mechanics 325An Ordinary Visitor 327Visitor Cycles 333Visitor Risks 338Summary 340Part VI Appendixes 341Appendix A Directions 343Get the Most from This Book 343Understand the Classics 344Weave Patterns into Your Code 344Keep Learning 345Appendix B Solutions 347Appendix C Oozinoz Source 427Acquiring and Using the Source 427Building the Oozinoz Code 427Testing the Code with JUnit 428Finding Files Yourself 428Summary 429Appendix D UML at a Glance 431Classes 432Class Relationships 433Interfaces 435Objects 436States 437Glossary 439Bibliography 447Index 449

最近チェックした商品