1. Why the bridge design mode?
Let's talk about the differences between integrated components and independent components in computer hardware. Let's talk about integrated components first.
The memory box contains a theme called a motherboard, which is used to plug in various components, such as sound cards, video cards, and hard disks, and then coordinates these components for work.
In fact, the earliest co
Written before: The meaning of the design pattern is to solve the actual design problems, the reason why the poor understanding is because there is no personal experience, so to keep learning practical thinking.Bridge is translated as bridging. Since there must be two objects bridged for bridging. This article intends to analyze the bridging mode from three aspects.1. What are the two objects bridged? 2. How to Br
Motivation : ThinkPad has multiple models, such as T43 and t60. Each model supports multiple working modes. Each model has different implementations in different modes. With the continuous development, there are more and more models and working models. How to separate ThinkPad from the changes in model and working mode so that they change independently, without introducing additional complexity (the complexity caused by the constant inheritance of the
ArticleDirectory
1.1 send a prompt message
1.2 non-use mode solution
1.3 what's the problem?
To write a new and familiar design pattern. It is also a very practical design pattern, that is, the Bridge pattern.
Many friends are not familiar with this design pattern. Many people often see or subconsciously use this pattern, but do not know it. The
Bridge mode (bridge structure mode) C # simple ExampleEach additional action in the previous player must be added to each player, and the behavior is extracted by bridging mode to reduce the change?
123456789101112131415161718192021222324252627282930313233343536
Abstraction should not depend on implementation details. Implementation Details should depend on abstraction.
Motivation ):
Some businesses have multiple changing perspectives.
Intent (Intent ):
The abstract part is implemented in part separation so that they all change independently.
Structure)
Bridge Mode:
(1) The Bridge
() ;}// kuwo public class kuwo: isoftware {public void start () {console. writeline ("listen to music, use cool! ") ;}}// Weixin public class Weixin: isoftware {public void start () {console. writeline (" brings you closer to me! ");}}
Operating System Code
// Operating system, run the software public abstract class system {public abstract void run (isoftware software);} // WP public class winphone: system {public override void run (isoftware software) {console. writeline ("winphone system, giv
definition, it is an underlying implementation;As can be seen from the above, the bridge mode has two parts: the abstract part and the realization part; The implementation is partially used for the specific underlying implementation, and the abstraction is used to encapsulate the specific underlying reality, and the interface definition can be different;5. InheritanceWhat is inheritance? Inheritance is a r
hierarchy of classes and classes will remain relatively small, which is unlikely to grow into an uncontrollable giant. Bridge Mode: separates the abstract part from the implementation part so that they can all change independently. Since there are multiple implementation methods, the core intention of the bridge mode
Bridging mode separates abstraction (abstraction) from implementation (implementation), allowing the two to change independently.
The typical structure diagram for bridging mode is:
As you can see in the structure diagram of the bridging pattern, the system is divided into two relatively independent parts, the left is an abstract part, the right is the implementation part, the two parts can be modified
Bridge Mode in Design Mode
Bridge, as the name suggests, builds a bridge between two objects that have a relationship. The two objects can be independent of each other, reducing coupling and solving the strong dependency between inheritance.
For example, there are many elect
Two modes of OpenWrt: Bridge mode and route mode 1, bridging mode (bridged AP mode): Bridge through OpenWrt device, A wireless device connected to the OPENWRT is assigned an IP address from the route in the 192.168.1.0 segment
Tags: Bridging Mode Nat VMware network networking Bridged networking (Bridging Mode)In this mode, the Virtual Operating System of VMware is like an independent host in the LAN, which can access any machine in the network. In the bridge mode, you need to manually configure t
About the role of the JDBC Bridge connection mode for a long time, if the wrong place to hope that the great God can point out, thank you very much .... Be sure to point out that ...
Give me a jdbc little chestnut.
Step one: Establish a bridge-connected interface
Public interface Jdbc_api {public
void connection ();
Step Two: Create multiple classes (sim
Bridge Mode
1. Intention
Separate the abstract part from its implementation part so that they can all change independently.
(Open and closed principles of class design: open to extensions and close to modifications)
Two motivations
LookArticleExample: Implementation of the abstract Part of the portable window and its extension method
1. To add a new window type, you must add a new window c
Design Mode-Bridge ModeBridge: separates abstract and implementation parts so that they can all change independently. Understanding: To solve the problem of changing an object and affecting multiple objects, we need to abstract specific objects so that the coupling between objects and change factors can be reduced and the maintainability and scalability of the system can be improved. For example, the mobile
).
Whether it's a new hardware platform or a new OS, everyone can focus on their own fields. That is, the external world is greatly changed, but the impact on this model is very small.
// Operating system class OS {public: Virtual void run () {}}; // windowsclass windowos: Public OS {public: void run () {cout
Ii. Bridging Mode
Definition:Separates abstract parts from their implementations so that they can all change independently..
In oth
Design mode of bridge pattern structureDefined:
Separate the abstract and implementation sections so that they run independently.
Avoid using inheritance to cause the number of system classes to burst, consider bridging mode.
Bridging mode translates inheritance relationships into associations, reduces
Intent/Definition: separates a set of implementations from the objects used by the other group so that they can change independently.
Problem: Multiple Derived classes of an abstract class must use multiple implementations, but class explosion is not allowed.
Solution: Define an interface for all implementations for use by all the derived classes of the abstract class.
Participants and collaborators: the concrete implementation of the abstract class uses the derived class of the implementation c
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.