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

What problems does the web policy model solve?

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

Share

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

This article focuses on "what problems have been solved by the web strategy model". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what problems have been solved by the web strategy model"?

Effect.

Generally speaking, the processing of most programs can also be regarded as data processing, and the process of data processing can be divided into input data, data processing and output data. The strategy model focuses on dealing with the selection and expansion of data.

The change in the way data is processed can first of all be the choice of processing method. There are usually several known ways to choose from in this case. Take the calculation of loan interest as an example, there are generally two ways: the same amount of principal and interest and the same amount of principal, and the specific choice is agreed upon by both parties to the contract. A selection processing like this is usually a selection statement in the code. The selection used by the program determines which branch to enter. Each time you increase the calculation method, you need to modify the judgment statement to add additional options. This is true even if all other code has nothing to do with this change.

There is an alternative when you need to extend functionality. In the previous example, we can decompose the process, prepare the part of the data, separate it from the post-processing, and separate it into an abstract method. So every time you need to add a new way of processing, you just need to derive a new class and implement the abstract method. In this case, the relationship between the derived class and the base class is [is a]. The problem with this approach is that although the content of the derived class may only contain the content of data processing, this part of the content exists as part of the base class processing, and there is no way to apply it to other situations. Another point is that if data processing classes need to be extended in other aspects, the number of derived classes will increase significantly.

The third way is to use the strategy pattern, and the first step is still to decompose the process and separate the real data processing from pre-preparation and post-processing. The next approach is slightly different, and the policy pattern is to separate the data processing part into a policy class. When you need to choose or extend data processing, just replace the policy class. In this case, there is a [has a] relationship between the entire data processing class and the policy class. Its advantage is that the policy part exists independently of the whole data processing class, so it is convenient to replace and expand, and it can also be applied to other situations without any modification.

At this point, I believe you have a deeper understanding of "what problems have been solved by the web strategy model". 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.

Share To

Internet Technology

Wechat

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

12
Report