Design pattern (c + + implementation)--a sentence summary __c++

Source: Internet
Author: User

Original link: http://blog.csdn.net/LCL_data/article/details/12117349

according to the purpose, the design pattern can be divided into the creation pattern, the structure pattern and the behavior pattern.

According to the purpose, it can be divided into the creation pattern, the structure pattern and the behavior pattern.
Create Pattern: Factory mode (factory method, abstract factory, builder, prototype, single case)
Structured mode: Connection mode (adapters, bridges, combinations, modifiers, skins, privileges, agents)
Behavioral patterns: Responsibility chains, commands, interpreters, iterators, intermediaries, memos, observers, States, policies, template methods, and visitor patterns.

The creation pattern is used to process the creation of objects, which are used to handle the combination of classes or objects, and behavioral patterns are used to describe how classes or objects interact and how responsibilities are assigned.


The creation pattern is used to process the creation of an object, consisting mainly of the following 5 type of design pattern:

1, the intent of the factory method model (Factory methods pattern) is to define a factory interface that creates product objects and defer actual creation to subclasses.

2, the intent of Abstract Factory mode (abstract Factory pattern) is to provide an interface to create a series of related or interdependent interfaces without specifying their specific classes.

3, the intent of the builder model (Builder pattern) is to separate a complex build from its representation, so that the same build process can create different representations.

4, prototype mode (Prototype pattern) specifies the type of object to create with a prototype instance, and creates a new object by copying the prototypes.

5, Singleton mode (Singleton pattern) is to ensure that a class has only one instance and provides a global access point to access it.

a structured pattern is used to handle a combination of classes or objects, consisting mainly of the following 7 design patterns:

6, Adapter mode (Adapter pattern) Converts the interface of a class into another interface that the customer wishes. These classes can work together because the interfaces are incompatible and cannot work together.

7, bridging pattern is the separation of the abstract and the actual parts so that they can be changed independently.

8, Combinatorial mode (composite pattern) is a hierarchical structure that combines objects into a tree structure to represent "part-whole". Enables users to have consistency with the use of a single object and a grouped object.

9, the Decorator mode (decorator pattern) dynamically adds some additional responsibilities to an object. This pattern is more flexible than generating subclasses in terms of adding functionality.

10, the façade pattern is a consistent interface for a set of interfaces in a subsystem that defines a high-level interface that makes the subsystem easier to use.

11, the Flyweight pattern is a shared way to efficiently support a large number of fine-grained objects.

12, proxy pattern is to provide a proxy for other objects to control access to this object.


behavioral patterns are used to describe how classes or objects interact and how responsibilities are assigned, including the following 11 design patterns:

13, the responsibility chain mode (Chain of responsibility pattern), in which many objects are connected by each object's reference to their house to form a chain. The request is passed on this chain until an object on the chain decides to process the request, which allows the system to dynamically rearrange the chain and assign responsibility without affecting the client.

14, command pattern is to encapsulate a request into an object that allows you to parameterize clients with different requests, queue or log request logs, and support revocable operations.

15, the Interpreter mode (interpreter pattern) describes how to define a grammar for a simple language, how to represent a sentence in that language, and how to interpret these sentences.

16, the iterator mode (iterator pattern) provides a way to access the elements of an aggregation object without exposing the internal representation of the object.

17, the Mediator mode (mediator pattern) defines a mediation object to encapsulate the interaction between the series objects. The Terminator makes the objects not need to be shown to call each other, so that they are loosely coupled and can independently change their interactions.

18, the memo mode (Memento pattern) captures the internal state of an object without destroying the encapsulation, and saves the state outside the object.

19, the Observer mode (Observer pattern) defines a one-to-many dependency between objects, and when an object's state changes, all objects that depend on it are notified and automatically updated.

20, state pattern is the behavior that allows an object to change its internal state as it changes, making the object appear to modify its class.

21, the Strategy mode (strategy pattern) is to prepare a set of algorithms and encapsulate each algorithm so that they can be interchanged.

22, Template Method Patterns (Template) allow subclasses to redefine certain steps of the algorithm without altering the structure of an algorithm.

23, the Visitor mode (Visitor pattern) represents an operation that acts on the elements of an object structure, allowing you to define new operations that act on these elements without changing the classes of each element.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.