(轉貼) Design Pattern週期表 (OO) (Design Pattern)
轉貼自http://home.earthlink.net/~huston2/dp/patterns.html
GoF Design Patterns
- amazon.com
- download GoF source
- Table of Intents
- Table of Mnemonics (1 column)
- Table of Mnemonics (3 column)
- UML diagrams of all 23
- GoF design class diagrams quiz
- Non-Software Examples article
- Who ya gonna call?
- Creational patterns
- Abstract Factory | C++ demos | Java demos | lab
- Builder | C++ demos
- Factory Method | C++ demos | lab
- Prototype | C++ demos | Java demos | lab
- Singleton | C++ demos | lab
- Structural patterns
- Adapter | C++ demos | Java demos | lab
- Bridge | C++ demos | Java demos | Bridge = insulation | lab
- Composite | C++ demos | Java demos | lab
- Decorator | C++ demos | Java demos | Decorator vs Chain | lab
- Facade | C++ demos | Java demos
- Flyweight | C++ demos | Java demos | lab
- Proxy | C++ demos | Java demos | lab
- Behavioral patterns
- Chain of Responsibility | C++ demos | Java demos | Chain vs Decorator | lab
- Command | C++ demos | Java demos | lab
- Interpreter | C++ demos | un-demo | article
- Iterator | C++ demos | Java demos | lab
- Mediator | C++ demos | Java demos | lab
- Memento | C++ demos | lab
- Observer | C++ demos | Java demos | lab
- State | C++ demos | Java demos | pattern vs table | article | lab
- Strategy | C++ demos | Java demos | lab
- Template Method | C++ demos | Java demos | lab
- Visitor | C++ demos | Java demos | lab
- State, Template Method demo (rubber banding)
- Composite, Builder, Iterator, Memento, Visitor demo
- Command, Chain demo
- Mediator, Observer demo
- Mediator + Observer = Event Notifier (article)
- Java's new Considered Harmful - Singleton, Flyweight, Factory Method, Abstract Factory, Prototype (article)
- File system (Template Method)
File system (Composite, Proxy, Chain, Iterator, Visitor, Observer, Command)
File system (7 previous patterns, Decorator)
| |
GoF Structure Similarities | |
| |
Left-Right symbol = wrapper/wrappee or delegation or "has a" relationship Adapter ... wrap a legacy object that provides an incompatible interface with an object that supports the desired interface Facade ... wrap a complicated subsystem with an object that provides a simple interface Proxy ... wrap an object with a surrogate object that provides additional functionality |
|
| |
Up-Down symbol = inheritance hierarchy (promote interface to a base class and bury implementation alternatives in derived classes) Strategy ... define algorithm interface in a base class and implementations in derived classes Factory Method ... define "createInstance" placeholder in the base class, each derived class calls the "new" operator and returns an instance of itself Visitor ... define "accept" method in first inheritance hierarchy, define "visit" methods in second hierarchy ... a.k.a. "double dispatch" |
|
| |
Category: a wrapper wraps an inheritance hierarchy Builder ... the "reader" delegates to its configured "builder" ... each builder corresponds to a different representation or target State ... the FiniteStateMachine delegates to the "current" state object, and that state object can set the "next" state object Bridge ... the wrapper models "abstraction" and the wrappee models many possible "implementations" ... the wrapper can use inheritance to support abstraction specialization Observer ... the "model" broadcasts to many possible "views", and each "view" can dialog with the "model" |
|
| |
Category: recursive composition Composite ... derived Composites contain one or more base Components, each of which could be a derived Composite Decorator ... a Decorator contains a single base Component, which could be a derived ConcreteComponent or another derived Decorator Chain of Responsibility ... define "linked list" functionality in the base class and implement "domain" functionality in derived classes Interpreter ... map a domain to a language, the language to a recursive grammar, and the grammar to the Composite pattern |
|
| |
Cloud symbol = promote X to "full object status" Command ... encapsulate an object, the method to be invoked, and the parameters to be passed behind the method signature "execute" Iterator ... encapsulate the traversal of collection classes behind the interface "first..next..isDone" Mediator ... decouple peer objects by encapsulating their "many to many" linkages in an intermediary object Memento ... encapsulate the state of an existing object in a new object to implement a "restore" capability Prototype ... encapsulate use of the "new" operator behind the method signature "clone" ... clients will delegate to a Prototype object when new instances are required |
|
| |
Category: miscellaneous Abstract Factory ... model "platform" (e.g. windowing system, operating system, database) with an inheritance hierarchy, and model each "product" (e.g. widgets, services, data structures) with its own hierarchy ... platform derived classes create and return instances of product derived classes Template Method ... define the "outline" of an algorithm in a base class ... common implementation is staged in the base class, peculiar implementation is represented by "place holders" in the base class and then implemented in derived classes Flyweight ... when dozens of instances of a class are desired and performance boggs down, externalize object state that is peculiar for each instance, and require the client to pass that state when methods are invoked Singleton ... engineer a class to encapsulate a single instance of itself, and "lock out" clients from creating their own instances |
|
|
Books
- Head First Design Patterns | amazon | sample chapter | downloads | your brain poster | head first labs
- Pattern-Oriented Software Architecture | amazon | Table of Intents | Layers | Vol II Wiley | Vol II amazon
- Java Design Patterns: A Tutorial | amazon | download the PDF file
- Patterns in Java, Volume 1 | amazon | author's Web site
- Design Patterns Explained | amazon
- Design Patterns Java Workbook | amazon
- Applied Java Patterns | amazon
- C# Design Patterns: A Tutorial | amazon
- The Design Patterns Smalltalk Companion | amazon
- Pattern Hatching: Design Patterns Applied | amazon
- The Patterns Handbook | amazon
- Core J2EE Patterns | amazon | summary
- Pattern Languages of Program Design 1 | amazon | Table of Contents
- Pattern Languages of Program Design 2 | amazon | Table of Contents
- Pattern Languages of Program Design 3 | amazon | Table of Contents | Extension Object | C++ demo
- Pattern Languages of Program Design 4 | amazon | Table of Contents
- Pattern Languages of Program Design 5
- Analysis Patterns | amazon
- AntiPatterns | amazon | subset summary
- San Francisco Design Patterns | amazon | Table of Intents
- Concurrent, Parallel, and Distributed Systems | Doug Schmidt