The following is a summary of the notes I made when I studied "Big Talk design mode", some of which came from the author Geoscience. (thank him very much for setting up such a smooth learning channel for the mysterious design pattern.)
1. Create a type:
(1) Singleton: Consider only one instance.
(2) Factory method: Generally first solve object creation problem with factory method.
(3) Abstract Factory: When the factory method can not meet multiple series of problems, and then refactor into an abstract factory.
(4) Builders: The construction of multiple components is the same, only the required components, the construction sequence is not considered.
(5) Prototype: Consider when the initialization information is not changed.
2. Structural type:
(1) Adapter: The class that makes the interface incompatible can work together. Mend
(2) Decoration: Adding additional responsibilities to a single object dynamically, more flexible than generating subclasses.
(3) Bridging: Change the inheritance relationship to a composite relationship so that the two can vary independently. Rainy Day
(4) Combination: The hierarchical relationship of "whole-part" is represented by a tree structure, so that the use of a single object (leaf node) and a composite object (a stub point) is consistent.
(5) to enjoy: To use shared technology, to support a large number of fine-grained objects, save overhead.
(6) Agent: Controls access to a single object.
(7) Appearance: High-level interface of sub-system, avoid the third party of two kinds of direct relationship.
3. Behavioral Type:
(1) Observer: one-to-many dependencies, one end changes, multiple notifications and Automatic Updates. (The target and the observer can achieve weak coupling)
(2) Template method: Inherit + rewrite to resolve code duplication problem.
(3) command: The request sender and the specific implementation of the decoupling, the request can be arranged, canceled, redo, support transactions. (Multi-request, single processing)
(4) The Chain of responsibility: The processor is queued, and the request is passed along the chain. (Single request, multi-processing)
(5) State: When the state of the object is changed and the different operations are taken into account, the state transfer logic is not in If/switch, and the increment/change state and the state transition are easier between the subclasses.
(6) Interpreter: If a particular problem occurs when the frequency is high enough to consider, you need to define the grammar representation and the interpreter itself.
(7) Intermediary: The intermediary encapsulates a series of object interaction, reduces the coupling between objects, and facilitates reuse. (Many friends)
(8) Visitor: Consider when element is more stable and visitor is easy to increase. (Friends in the fine not many)
(9) Strategy: A series of algorithms are packaged individually and can be replaced, easy to switch, understand, expand.
(10) Memo: Do not destroy the package, but also take the state of the object, and require the state to consider when restoring. (Keep package boundary)
(11) Iterator: The access and traversal of the collection is detached from the collection object into the iterator.
Http://www.cnblogs.com/lzhlyle/p/4696645.html
The design pattern of a sentence (turn)