Design Pattern: Bridge Mode

Source: Internet
Author: User

Http://www.35java.com/zhibo/forum.php? MoD = viewthread & tid = 272 & extra = Page % 3d2

InGof booksThe purpose of the bridge mode is to "separate the abstract part from its implementation part so that they can all change independently ."

This sentence is short and further explained here. The abstract part refers to the definition of behavior, and the Implementation part refers to the dependency with a specific platform.Code.

An actual example is mentioned in the gof book. If you define an iwindow interface, this interface only defines some abstract plotting behaviors, without involving platform implementation, today, you can inherit this class to develop the XWindow class for X Window, or inherit this class to develop the WindowsXP class for Windows XP systems. To make good use of system resources, when you implement the iwindow interface, the System-related implementation code is written in the interface implementation.

Assume that you inherited the iwindow interface and wrote an i3dwindow interface. Expand a drawbox () method to draw 3D images. In short, the i3dwindow interface expands abstract behaviors, to enable the i3dwindow class to run in two different systems, XWindow and WindowsXP, you must write the system-related implementation code again.

In short, abstract behavior definitions are mixed with platform-related implementations. In order to separate abstract parts from their implementations, they can all change independently, you can use the following structure.

On the right, the implementation part related to the platform is separated from the development of the abstract line on the right. You can continue to develop the abstract part on the left, instead of binding specific platform implementation methods, the entire structure becomes increasingly elastic.

The structure of the bridge mode UML class is as follows:

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.