Bridge Mode: separates abstract parts from their implementations so that they can all change independently. The method to implement separation is to add a class,11. 1. Explanation
Main (), customer
IProduct, product Interface
CHouse, house
CIPod, ipod
CClothes, clothing
CNewCorp, bridge class, MakeMoney () is the Bridge
Bridge mode is the structure pattern of the object. Also known as the handle body (Handle and body) mode or interface (Interface) mode. The bridge model is intended to "decouple abstraction (abstraction) from implementation (implementation) so that they can vary independentl
Tags: des style blog HTTP color Io ar Java
In fact, it does not take three minutes, and three seconds is enough. Remember that the bridge mode is so simple: In a word, there are thousands of PEN shapes and tens of thousands of changes in painting.
The following only helps to understand.
1. Definition
TheBridge patternIs a design pattern used in software engineering which is meant"Decouple an independent act
Document directory
Gof Definition
Motivation
Key points of the Bridge Mode
Gof Definition
Separate the abstract part from the implementation part so that they can all change independently.
Let's look at a simple example. Suppose we need to develop a tank game that supports both PC and mobile phones. The game features the same on both PC and mobile phones and has the same type, there are also changes in
The bridge mode is a type of structural mode, while the strategy mode is a behavior mode. The following is their UML structure diagram.
In the bridge mode, the aggregate action refere
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
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
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
four specific implementation (medium cup with milk without milk) there is a concept overlap, because there is a medium cup with milk, there is also a medium cup without milk, if again in the Cup this layer to achieve two inheritance, is obviously chaotic, very poor extensibility. Then we use bridge mode to implement it. How to Implement Bridge
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
For example, the Null mode and Bridge Mode Programming in Python, pythonnull
Null ModeI think everyone has an experience. In order to obtain a certain attribute, but sometimes the attribute is None, you need to handle exceptions. If you want to save code for such conditional filtering, the Null mode can be used to redu
four specific implementation (medium cup with milk without milk) there is a concept overlap, because there is a medium cup with milk, there is also a medium cup without milk, if again in the Cup this layer to achieve two inheritance, is obviously chaotic, very poor extensibility. Then we use bridge mode to implement it.How to Implement Bridge modeTake the coffee
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
Bridge Mode
Separate the abstract part from its implementation part so that they can all change independently.
Analysis
1. Abastrction: an abstract class, which is implemented by Implementor.
2. Implementor: the abstract base class of the implementation class, which defines the basic operations for implementing the intent action, and its derived class implements these interfaces.
3. Implementor: OperationI
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.