Design Mode Summary (II)

Source: Internet
Author: User

There are three types of design patterns: Creation design patterns, structural design patterns, and behavioral design patterns.

I. Creation Design Model

In the design mode, the Creation Mode processes the design mode of the object creation process. It determines how to create an object based on the actual situation. The Creation Mode hides how class instances are created and put together. What the entire system knows about objects is interfaces defined by abstract classes. In this way, the creation mode provides great flexibility in what is created, who creates it, how it is created, and when it is created.

The creation mode is divided into the class creation mode and the object creation mode. The class Creation Mode delays object creation to the subclass; the object Creation Mode delays part of the object creation to the subclass. The creation design mode enhances the independence between objects and classes.

The creation mode is generally used in the following scenarios:

1. the creation of systems and objects is independent of each other.

2. A group of related objects are designed to be used together.

3. Hide the implementation process of the class library by displaying its interface

4. Create different representations of independent complex objects

5. Subclass implementation class created object

6. Class instantiation at runtime

7. The instance is scalable without modification

8. A class can only have one instance, and this instance can be accessed at any time

Ii. Structural Design Model

The Mechanism Design Pattern describes how to combine objects to obtain a larger structure, not a combination of interfaces and implementations. It solves the coupling problem between modules from the program structure.

The structure design mode combines objects to obtain a larger structure. The methods include unification, generalization, and separation.

1. Unification: Consistency

A topic of an object combination is described in a unified manner to facilitate the use and expansion of users. In Schema mode, the adapter mode and combination mode can be classified into the topic.

2. generalization: Improve Abstraction

In summary, it abstracts and extracts some objects and then provides them to users. In this way, it is convenient for users to use and extend and maintain the summarized objects at the bottom layer. In the structure mode, the mode that can be classified into the topic has the appearance mode.

3. Separation: reduces coupling and facilitates Expansion

Separation can be said to be a topic of many models, not only structural models, but also a large number of design models with separation as the topic in the creation model. Separation can be used to decouple and enhance the independence between objects. In the Schema mode, the following modes can be classified into the topic: Bridging Mode, decorator mode, metadata mode, and proxy mode.

Iii. behavioral design model

The Design of behavior patterns to the assignment of duties between algorithms and objects not only describe the patterns of objects or classes, but also describe the communication modes between them, and describe the complex control flow that is difficult to trace during runtime, they shift your attention from the control flow to the relationship between objects. The behavior class mode uses the Inheritance Mechanism to distribute behavior among classes. The behavior object mode uses Object combination instead of inheritance. Some behavior object modes describe how a group of peer-to-peer objects collaborate to complete tasks that cannot be completed by any of the objects; other behavior object modes often encapsulate behavior in an object and assign requests to it.

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.