Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Which two issues need to be considered when using web bridging mode

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "which two problems need to be considered when using web bridging mode". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "which two problems need to be considered when using web bridging mode" can help you solve your doubts.

Effect of using bridging mode

One of the characteristics of object-oriented is encapsulation, which simply means putting an interface on the outside of the implementation. But the result is that the definition of the interface is tied to the implementation of the interface. The bridging mode separates the implementation from the interface and abstracts it. This makes it easy to replace the implementation at run time. For example, we can design a communication port to switch the communication mode from Wifi to Bluetooth when the program is executed.

In the bridging mode, the code that really implements the function is contained in the concrete class of the implementation class, physically separate from the interface class. Both can be compiled at different times, or they can be developed by different teams. This can bring great convenience to the management of development.

Hierarchical structure often appears in software development, and the easiest way to implement it is to use the idea of bridging pattern to regard the lower layer as the realization of the upper layer, that is to say, let the upper structure hold the pointer of the lower layer. Also with the communication port class, we can divide it into the protocol layer, and the physical path layer and let the protocol layer manage the pointers of the physical path layer.

further more

There are two issues to consider when using bridging mode:

1. How to distinguish between interface and implementation.

In a nutshell, interface classes should define functions in the user domain. Also take the communication port as an example, users need possible to send commands and receive on-site data, as for whether through Wifi or Bluetooth, whether to encrypt and other users do not need to care, are implementation-level matters.

two。 How to judge whether or not to separate and abstract the implementation part.

As long as you distinguish which are interfaces and which are implementations, there are only a limited number of options:

0) do nothing

1) the implementation will be partially independent of private methods.

2) separate the implementation into separate classes.

3) abstracts the implementation part and implements the function in the concrete class.

In the above cases, the degree of separation and abstraction is getting deeper and deeper. But if you think about it, except from 0) to 1), none of the changes involve logic, and most of the work can be done as long as the code is moved. So there's really no need to struggle, just do it wherever you see it.

After reading this, the article "which two problems need to be considered when using web bridging mode" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report