Design pattern Opening overview (Java)

Source: Internet
Author: User

  The design principle is the norm, the design pattern is the skill. if the basic knowledge can be flexibly applied in the project, then I am sure I will get the unexpected harvest.

In the next time, I will continue to learn design patterns, will be on each design pattern from the following points for analysis and learning, if inappropriate or understand the wrong place, welcome to correct and criticize:

(1) definition : Describe what the pattern is and what role it has;

(2) description of the problem: the model is for what kind of problems arise, by the development of problems encountered in the introduction;

(3) solution : Give the appropriate solution to further explain the definition of the model;

(4) structure diagram : According to the definition, draw the related chestnut UML structure diagram;

(5) to give a chestnut : A concrete example is given to further illustrate the mode of implementation;

(6) Advantages and disadvantages : Systematically analyze the advantages and disadvantages of the model;

(7) application Scenario : Summary, summarize the pattern of the use of the scene.

Let's take a general look at the definition of the 24 design patterns, with a general impression on these design patterns:

1. Simple Factory mode : It is the responsibility to create instances of other classes by specifically defining a factory class, and the instances that are created usually have a common parent class.

2. Factory Method Mode : Defines a factory interface that creates product objects, deferring actual creation to subclasses.

3. Abstract Factory mode : Provides an interface for creating a set of related or interdependent objects without specifying their specific classes.

4. Singleton mode : One class has and only one instance, and self-instantiation is provided to the system as a whole.

5. prototype mode : Use the prototype instance to specify the kind of objects created and create new objects by copying them.

6. Builder Mode : separates the construction of a complex object from its representation so that the same build process can create different representations.

7. Adapter Mode : Transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together because of an interface mismatch can work together.

8. Bridging mode : The abstraction and implementation are decoupled so that they can change independently.

9. Combination mode : Combines objects into a tree structure to represent a "partial-whole" hierarchy, which makes the user consistent with the use of individual objects and composite objects.

Decorative Mode : The ability to dynamically extend an object without having to change the original class file and use inheritance.

One. appearance mode : Provides a consistent interface for a set of interfaces in a subsystem, defining a high-level interface that makes this subsystem easier to use.

enjoy meta mode : Use sharing technology to effectively support a large number of fine-grained objects.

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

Responsibility Chain Mode : Many objects are linked together by each object's reference to its next level, and the request is passed through the chain until an object on the chain decides to process the request, thus avoiding the coupling between the sender and the recipient of the request.

The command pattern : To abstract a set of behaviors into objects, and to achieve loose coupling between them.

The interpreter pattern : Provides a way to evaluate a language's syntax or expression, implementing an expression interface that interprets a specific context.

The iterator pattern : Provides a way to sequentially access various elements in an aggregated object without exposing the internal representation of the object.

Mediator Mode : Use a Mediation object to encapsulate a series of object interactions, so that the intermediaries do not need to interact with each other, so that they are loosely coupled and can independently change the interaction between them.

Memo Mode : captures the internal state of an object without breaking the closure, and saves the state outside of the object so that it can be restored to its original saved state later.

The Observer pattern : 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.

State mode : Allows an object to change its behavior when its internal state changes, and the object looks as if it has modified its class.

Policy Mode : Defines a series of algorithms, encapsulates each algorithm, and allows them to be replaced with each other, allowing the algorithm to be independent of the client that uses it.

Template Method Pattern : A framework for manipulating algorithms is defined in the parent class, and some steps are deferred to subclasses to implement, so that subclasses can redefine some specific steps of the algorithm without altering the framework structure of an algorithm.

The visitor pattern : Encapsulates actions that act on elements of a data structure, and it can define new operations that act on the resulting element without altering the data structure.

Reference: Baidu Encyclopedia

Design Patterns | Beginner's Tutorial

Design pattern Opening overview (Java)

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.