-23 kinds of design patterns Design patterns introduction

23 design patterns Introduction


  • Singleton (the Singleton) mode: only generate an instance of a class, a class provides global access point for external acquire this example, which is limited cases of expansion mode.
  • Prototype (the Prototype) mode: an object as a prototype, be copied by a plurality of cloned prototypes of a new instance, and the like.
  • Factory method (Factory Method) mode: Define an interface for creating a product, what products subclasses decide by the manufacturer.
  • Abstract Factory (AbstractFactory) mode: create a product family of interfaces, each subclass can produce a series of related products.
  • Builder (Builder) mode: a complex object into a plurality of relatively simple part, create them according to different needs and, respectively, into the final construct complex objects.
  • Proxy (Proxy) mode: an object to provide an agent for controlling access to the object. I.e., indirectly via a proxy client to access the object, thereby limiting, enhance or modify some features of the object.
  • Adapter (Adapter) mode: converting a class interface clients expect another interface, such as those due to incompatible interfaces based otherwise not able to work together with the work.
  • Bridge (Bridge) mode: an abstraction and separation, so that they may be varied independently. It is achieved by a combination relationship instead of inheritance, and abstraction implemented to reduce the dimensions of the two variable degree of coupling.
  • Decoration (Decorator) mode: Dynamic Object to add some responsibilities, namely to increase its extra features.
  • Appearance (the Facade) mode: providing a consistent interface to multiple complex subsystems, these subsystems are more easily accessible.
  • Flyweight (Flyweight) mode: Use sharing to support effective reuse a lot of fine-grained objects.
  • A combination of (Composite) mode: the objects into the hierarchy tree, so that the user has access to the same combination of the object and the individual objects.
  • Template Method (TemplateMethod) mode: the algorithm defines a skeleton of operation, some steps of the algorithm to delay subclasses, subclasses may not change so that certain steps of the algorithm in the case of the algorithm structure redefined.
  • Strategy (Strategy) mode: it defines a set of algorithms, and each algorithm package together, so that they can replace each other, and the algorithm change does not affect customers using the algorithm.
  • Command (Command) mode: Encapsulate a request for an object, so that execution of the request and Responsibility requesting separated.
  • Duty chain (Chain of Responsibility) mode: the request transmitted to the next object in the chain from an object, up until the request is acknowledged. Removing the coupling between objects in this way.
  • State (State) mode: allows an object to change its capacity when its internal state changes.
  • Observers (Observer) mode: many relationship between a plurality of objects, when an object is changed, the change is notified to the plurality of other objects to affect the behavior of other objects.
  • Mediator (Mediator) mode: Define a mediation object is to simplify the interaction between the original target, reducing the coupling between objects in the system, so that between each other without having to know the original target.
  • Iterator (the Iterator) mode: to provide a sequential access method to a series of data objects in the polymerization, the polymerization without exposing the internal representation of the object.
  • Visitors (Visitor) mode: a collection of elements without changing the premise of providing a variety of ways to access a set of each element, i.e. each element has a plurality of visitor access objects.
  • Memorandum (Memento) mode: without destruction of the package, obtains and stores the internal state of an object, in order to recover it later.
  • Interpreter (Interpreter) Mode: how to define the grammar provides language and interpretation of language sentence, i.e., interpreter.

Pattern Classification


Range / destination Create a schema Structural model Of behavioral patterns
Class mode Factory Method (Class) adapter Template method, the interpreter
Object Model

Singleton

prototype

Abstract Factory

builder

proxy

(Object) Adapter

bridging

decoration

Exterior

Flyweight

combination

Tactics

command

Chain of Responsibility

status

Observer

Mediator

Iterator

Visitors

memorandum

Guess you like

Origin www.cnblogs.com/TechSingularity/p/12157147.html