Design mode Complete Memo

Source: Internet
Author: User
Tags abstract

Recently was learning design patterns, see this person summed up very well, and turned around. than I always remember clearly. Concise.

Small words: This is not the design mode to explain the blog post, the following will design patterns of overview, class diagram, code examples, summary of each blog post alone, and now classify it, easy to read later, design mode is not a month or two after learning to fully understand, it only tells us a few solutions to the problem of ideas and methods, The specific problem is abstracted into the idea of the model, martial arts is also, the routines need to learn, but the basic skills (such as horse, strength, perseverance, anti-impact ability) absolutely indispensable, in learning design patterns and more need to look at the data structure and algorithm aspects of the basic stuff. Design mode is not a silver bullet, if it is not to use the Dragon 18 palm against an ant is not a good idea. I am also not fine, the collation of the inevitable mistakes, I hope in the criticisms of everyone, common progress.

First, create a model factory method (Factorymet Hod

Defines an interface for creating objects, letting subclasses decide which class to instantiate.

FactoryMethod defers the instantiation of a class to its subclasses.

Abstract Factory (Abstractfactory)

Provides an interface to create a series of related or interdependent objects without specifying their specific classes.

Builders (builder)

Separating the construction of a complex object from its representation allows the same build process to create different representations.

Singleton mode (Singleton)

Ensure that a class has only one instance and provides a global access point to access it.

Prototype mode (PROTOTYPE)

Use the prototype instance to specify the kind of object to create and create a new object by copying the prototypes.

second, structural mode adapter mode (Adapter)

Transforms the interface of one class into another interface that the customer wants. Adapter mode makes the original

Those classes that cannot work together because of incompatible interfaces can work together.

Bridging mode (bridge)

Separate the abstract part from its implementation, so that they can all change independently.

Combination Mode (Compsite)

Combines objects into a tree structure to represent a "partial-whole" hierarchy.

"Composite makes the user consistent with the use of individual objects and composite objects. "

Decorative mode (Decorator)

Add some extra responsibilities to an object dynamically. Decorator mode is more flexible than generating subclasses in terms of added functionality

Appearance mode (facade)

Provides a consistent interface for a set of interfaces in a subsystem, facade mode defines a high-level interface,

This interface makes this subsystem much easier to use.

Enjoy meta mode (Flyweight)

Use shared technology to effectively support a large number of fine-grained objects.

Agent mode (proxy)

Provides a proxy for other objects to control access to this object.

Ii. Behavioral Model responsibility chain model (Chain of Responsibility)

Enables multiple objects to have the opportunity to process requests, thus avoiding the coupling between the sender and receiver of 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;

Queues or logs request logs for requests, and supports undoable operations.

Interpreter mode (interpreter)

Given a language, define a representation of its grammar, and define an interpreter,

This interpreter uses this representation to interpret sentences in a language.

Iterator mode (Iterator)

Provides a way to sequentially access individual elements in an aggregated object without exposing the object's internal representation.

Broker Mode (mediator)

Encapsulates a series of object interactions with a mediation object. The mediator makes the objects do not need to explicitly cross-reference each other.

This allows them to be loosely coupled and can independently change the interaction between them.

Memo Mode (Memento)

captures the internal state of an object without compromising encapsulation, and saves the state outside that object.

The object can then be restored to its previously saved state.

Observer Mode (OBSERVER)

Defines a one-to-many dependency between objects, when the state of an object changes,

All objects that depend on it are notified and automatically updated.

Status mode (state)

When an object's internal state changes to allow its behavior to change, the object looks like it has changed its class.

Policy mode (strategy)

Define a series of algorithms, encapsulate them one by one, and make them interchangeable with each other.

This mode allows the algorithm to be independent of the customers who use it.

Template Method (Templatemethod)

Defines the skeleton of an algorithm in an operation, and delays some steps into subclasses.

Templatemethod allows subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm.

Visitor Mode (Visitor)

Represents an operation that acts on each element in an object structure.

It allows you to define new actions that act on these elements without changing the class of each element.

attach a code example for each pattern, each of the sample code is debugged, debugging the environment vs2010

Download Address: Http://


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: 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.