Java and patterns-26-day series-conclusion-Summary of design patterns

Source: Internet
Author: User

Purpose:

-Creational: creates an object.

-Structural: A combination of processing classes and objects.

-Behavior Model (behavioral): The Responsibility Assignment in the interaction between classes and objects.

Creation Mode

Structural Mode

Behavior mode

1. abstractfactory

1. Adapter mode Adapter

1. responsibility chain mode chain of responsibility

2. Builder mode Builder

2. Bridge Mode

2. Command mode

3. Factory method mode

3. Composite

3. interpreter mode Interpreter

4. Prototype

4. decorator

4. iterator mode iterator

5. Singleton

5. Appearance mode Facade

5. mediator Mode

6. flyweight

6. Memento

7. Proxy Mode

7. Observer Mode Observer

8. State

9. Strategy Mode strategy

10. template method mode Template Method

11. Visitor mode visitor

 

In terms of scope:

-The class mode processes the static relationship between the class and the subclass.

-The object mode processes the dynamic relationship between objects.

The design patterns differ in granularity and abstraction layers. Because there are many design patterns, we can organize them in one way. Here, we classify the modes based on the two criteria, as shown in the following table:

The first is the objective principle, that is, what work the mode is used to accomplish. The schema can be divided into three types based on its purpose: creational, structural, or behavioral. The creation mode is related to object creation. The structure mode processes the combination of classes or objects. The behavior mode describes how classes or objects interact and how responsibilities are assigned.

The second is the range criterion. The specified mode is mainly used for classes or objects. The class mode processes the relationships between classes and subclasses. These relationships are established through inheritance and are static, and are determined at the Compilation Time. The object mode processes the relationships between objects. These relationships can change and be more dynamic at runtime. In a sense, almost all models use an inheritance mechanism. Therefore, "class mode" only refers to the modes that focus on handling inter-class relationships. Most of the modes belong
In the scope of object mode.

The createtype class mode delays part of object creation to subclass, while the createtype Object Mode delays it to another object. The structure class mode uses the Inheritance Mechanism to combine classes, while the structure Object Mode describes the object assembly method. The behavior class mode uses inheritance to describe the algorithm and control flow, while the behavior Object Mode describes how a group of objects collaborate to complete tasks that a single object cannot complete.

There are also other ways of organizing. Some modes are often used together. For example, composite (combination mode) is often used together with iterator (iterator mode) or visitor (visitor mode). Some modes are alternative, for example, prototype (prototype) is often used to replace Abstract Factory (Abstract Factory mode). Some patterns produce similar design results despite different intentions. For example, the composite structure is similar to the decorator structure.

Another way is to organize the design pattern based on how they reference each other described in the "related pattern" section of the pattern. A Graphical description of the mode relationship is provided.

 

Obviously, there are many ways to design patterns in the Organization. Thinking from multiple perspectives helps to improve their functions
Differences and application scenarios.

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.