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: |