Design Mode Study Notes-Bridge

Source: Internet
Author: User
1. Intention: Separate the abstract part from the implementation part so that they can all change independently.
It is understood that the abstraction and implementation in this sentence do not refer to the implementation of abstract classes and subclasses in OO, but "separating the changes of multiple dimensions in one thing ".
The abstract part in this sentence is separated from the implementation part. You can join the tank and platformimplementation examples of Li Jianzhong.
2. Key points:
A. combination:
Bridge decouples the inherent binding relationship between abstraction and implementation using the "Composite relationship between objects. The abstraction (tank model) and implementation (different platforms) can be changed along their respective dimensions.
Basis: combination is better than inheritance.
For example, in the tank abstract class, the platform is injected through the constructor.
B. Subclass:
What is abstraction and implementation changing along their respective dimensions? -- Subclass.
The abstraction and implementation Change along their respective dimensions, that is, they are "subclass. For example, different tank models and different platform subclasses. After obtaining the sub-classes, you can combine them to obtain different models on different platforms.
C. Similar to multi-inheritance schemes, but better than multi-inheritance.
D. Apply bridge when there are two very strong dimension changes.
Sometimes, even if there are two changing dimensions, but one of the dimensions does not have a strong change, the two changes do not result in cross-border results, and bridge is not required.
E. bridge supports changes in N dimensions.
It is OK to combine multiple dimensions for multiple implementations.

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.