Bridge Mode: separates the abstract part from its implementation part so that the two can change independently. (To be honest, this is hard to understand !!!)
Abstract: The abstract class in the inheritance relationship. It is generally located at the upper layer and has nothing to do with the platform.
Implementation: The Implementation class in the inheritance relationship is generally located at the underlying layer, platform-related, and implementation details
I still don't understand it. Let's take a look at the example!
For example, for an operating system, the platform has nothing to do with high-level Code and is an abstract part, while the underlying Bootloader and driver are the implementation part and platform-related. Here we assume that the operating system has good portability, that is, it follows the dip principle.
Figure 1: Portable Operating System Model
As long as an operating system follows this model, it is highly portable. Let's take a look at how to easily port this operating system to different hardware platforms. Assume that you need to port it to the hardware platforms from Intel x86, arm2410, and AMD:
Figure 2: OS porting on different hardware platforms
So far, our operating system OS is still an abstract concept. We have not yet defined a specific operating system, such as Windows. If Windows follows this model and inherits the effect of the OS abstraction, it is conceivable that it should be as follows:
Figure 3: making windows portable
Next, Linux and MACOs. Note: jobs cannot be known.
Figure 4: Enable Linux and Mac OS to inherit OS
It was still discovered by Steve Jobs: (He said you are stupid, and you have made such junk things... It is inevitable to have a big fight with Steve Jobs (because you know that once you persuade Steve Jobs, he will take this idea into account, which is advantageous for the promotion of MACOs)
You explained to Steve Jobs: Once the OS is inherited, MacOS will naturally support countless chips such as arm, Intel, and AMD, and no longer have to worry about selecting chips ,,, you continue to talk a lot about Bala. Steve finally agreed to your practice.
Why did Steve finally agree? Maybe he understands that you have adopted a design model-the bridge model (also named Joe, no wonder Steve Jobs will agree ), this is indeed a good model, almost perfect. It can realize the unification of the software and hardware worlds.
Why is this the Bridge Mode? Let's take a look at the structure of the bridge mode, and you will suddenly realize:
Figure 5: Structure of the Bridge Mode
From the comparison between figure 4 and figure 5, we find the corresponding relationship:
OS -- modify action
Windows, Linux, and MACOs -- refined?action
Port interface -- implementor
Arm port interface implementation-concreteimplementora
Implementation of the intel X86 port -- concreteimplementorb
In turn, let's take a look at the definition of the Bridge Mode: separating the abstract part from its implementation part so that the two can change independently.
The new version of MACOs is listed, and MACOs can finally run on any platform. Once released, thanks to its friendly user interface, Windows will soon be eliminated ..... Steve Jobs smiled happily in heaven!