Reflection on design patterns (I)

Source: Internet
Author: User

In the past few days, the teacher told us about the design model. Let us re-baptism from the learning methods and understanding of various models. Here, I sorted out my notes and my feelings.

I. Structural

The structure mode processes the relationship between classes and classes, or between objects and objects.

1. Appearance mode-Facade

(1) This mode defines a high-level interface to make subclass easier to use and provides a unified interface.

(2) Advantages:

Separating users from Subsystems reduces their coupling, facilitates system maintenance, and provides better scalability.

(3) Principles:

Conforms to the Demeter law and violates the open and closed principle.

2. Bridge Mode-Bridge


, We can see the main architecture of the bridge mode. It abstracts from two dimensions, and then connects the two abstractions with an association (aggregation) Relationship to form what we call a bridge.

(1) Bridge pattern: separates abstract parts from their implementations so that they can all change independently. It is an object structure mode, also known as the handle and body mode or interface mode.

Example of writing a brush,

(2) Advantages:

The Bridge Mode separates the changes of the two independent dimensions to reduce coupling.

Avoid Multi-Level inheritance and reduce the number of child classes.

Easy to expand.

(3) Principles:

It complies with the principle of open/closed, dependency reversal, and merging/aggregation reuse.

3. Proxy mode-proxy


(1) when it is difficult to access an object, the proxy mode can use an object proxy to access another object, so as to complete some functions.

(2) Advantages:

Reduces system coupling, enhances scalability, improves system performance, and improves operation efficiency

(3) Principle

In line with the principle of open and closed, the Demeter Law

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.