Design patterns are a set of reusable, most known, categorized purposes, code design experience Summary. Design patterns are used in order to reuse code, make code easier for others to understand, and ensure code reliability. There is no doubt that design patterns in others in the system are multi-win; Design patterns make code production truly engineering; Design patterns are the cornerstone of software engineering, like the structure of a building.
Design patterns are divided into three types, creating patterns, structural patterns, behavioral patterns, a total of 23, in detail as follows:
Create Model:
Singleton mode, abstract Factory mode, builder mode, Factory mode, prototype mode.
Structural mode:
Adapter mode, bridge mode, decoration mode, combination mode, appearance mode, enjoy meta mode, proxy mode.
Behavioral mode:
Template method mode, command mode, iterator mode, observer pattern, Mediator mode, Memo mode, interpreter mode, state mode, policy mode, responsibility chain mode, visitor mode.
The following is an introduction to the dictionary order:
Abstract Factory: provides an interface to create a series of related or interdependent objects without specifying their specific classes.
Adapter (adapter mode): transforms the interface of one class into another interface that the customer wants. The adapter mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces to work together.
Bridge (bridging mode): separates the abstract part from its implementation, so that they can all change independently.
Builder (builder mode): separates the construction of a complex object from its representation so that the same build process can create different representations.
Chain of Responsibility (responsibility chain mode): to decouple the sender and receiver of the request, so that multiple objects have an opportunity to process the request. Link the objects together and pass the request along the chain until an object handles it.
Command mode: encapsulates a request as an object so that you can parameterize the customer with different requests, queue requests or log requests, and support actions that can be canceled.
Composite (combined mode): combines objects into a tree structure to represent a "partial-whole" hierarchy. It enables customers to have consistent use of individual objects and composite objects.
Decorator (decorative mode): dynamically add some additional responsibilities to an object. In terms of extension functionality, it is more flexible than generating subclasses.
Facade (appearance mode): provides a consistent interface for a set of interfaces in a subsystem, and the facade schema defines a high-level interface that makes this subsystem easier to use.
Factory Method (Factory mode): defines an interface for creating objects, letting subclasses decide which class to instantiate. The Factory method defers the instantiation of a class to its subclasses.
Flyweight (enjoy meta mode): use sharing technology to effectively support a large number of fine-grained objects.
Interpreter (parser mode): Given a language, defines a representation of its grammar and defines an interpreter that uses that representation to interpret sentences in the language.
Iterator (iterator mode): provides a way to sequentially access individual elements of an aggregated object without exposing the object's internal representation.
Mediator (mediation mode): uses a mediation object to encapsulate a series of object interactions. The mediator makes the objects not need to explicitly reference each other, so that they are loosely coupled, and can independently change the interaction between them.
Memento (Memo mode): captures the internal state of an object without compromising encapsulation, and saves the state outside that object. The object can then be restored to the saved state.
OBSERVER (Observer mode): defines a one-to-many dependency between objects so that when the state of an object changes, all objects that depend on it are notified and refreshed automatically.
Prototype (prototype mode): Specifies the kind of object created with the prototype instance, and creates a new object by copying the prototype.
Proxy mode: provides a proxy for other objects to control access to this object.
Singleton (singleton mode): guarantees that a class has only one instance and provides a global access point to access it. Singleton mode is one of the simplest design patterns, but it has many drawbacks for Java developers. In the September column, David Geary explored the singleton pattern and how to deal with these flaws in the face of Multithreading (multi-threading), class loaders (Classes Loaders), and serialization (serialization).
State mode: allows an object to change its behavior when its internal state changes. The object appears to have modified the class it belongs to.
Strategy (Policy mode): defines a series of algorithms, encapsulates them one by one, and allows them to be replaced by each other. This mode allows the algorithm to be changed independently of the customer using it.
Template Method mode: defines the skeleton of an algorithm in an operation, and delays some steps into subclasses. The Template method allows subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm.
Visitor (visitor mode): represents an operation that acts on elements in an object's structure. It allows you to define new actions that act on these elements without changing the class of each element.
Design Patterns-programming is a technology, more an art