In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "when to use Bridge mode", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "under what circumstances to use Bridge mode"!
Applicability
Bridge mode is used in some of the following situations:
You don't want to have a fixed binding relationship between the abstraction and its implementation. For example, this may be because the implementation should be selectable or switched while the program is running.
Generally speaking, the abstract class defines the interface, the concrete class is responsible for the implementation, and the code that implements the function is written directly in the corresponding method, which is called binding. The bridging pattern can be simply replaced after the implementation is partially separated into separate classes.
The abstraction of a class and its implementation should be extensible by generating subclasses. At this time Bridge
Expression enables you to combine different abstract interfaces and implementation parts and extend them separately.
You can use the same implementation class for multiple interface classes, or you can switch to multiple implementation classes for one interface class.
Changes to an abstract implementation part should have no impact on the customer, that is, the customer's code does not have to be recompiled.
You can replace the instance of the implementation class at run time and change the behavior of the class dynamically.
(C++) you want to completely hide the abstract implementation from the customer. In C++, the representation of the class is visible in the class interface.
In many cases, there are some implementation-related data members in the header file of C++. After using the bridge mode, this part of the content is moved to the concrete class of the implementation class, and the implementation details are hidden in the result.
As shown in the first class diagram in the intent section, there are many classes to generate. Such a class hierarchy means that you must decompose an object into two parts. Rumbaugh calls this class hierarchy "nested nested generalizations".
In the previous article, the author also mentioned that the permutation and combination of the functions of the class indicates the need to separate the implementation class from the interface class.
You want to share the implementation among multiple objects (perhaps using reference counting), but at the same time ask the customer not to know this.
A simple example is Coplien's String class [Cop92], where multiple objects can share the same string representation (StringRep).
Of course, the premise of sharing is to separate the parts that need to be shared.
At this point, I believe you have a deeper understanding of "under what circumstances to use Bridge mode". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.