In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is the entrustment mode of php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Delegation pattern is a basic skill in software design pattern. In delegate mode, two objects participate in processing the same request, and the object that accepts the request delegates the request to another object to process. Delegate pattern is a basic skill, and many other patterns, such as state pattern, policy pattern, and visitor pattern, essentially adopt delegate mode in more special situations.
Introduction to dynamic delegation: the concept of dynamic delegation comes from the Jakarta bytecode engineering library (Byte-Code Engineering Library, BCEL). It can analyze existing classes, and for interfaces, abstract classes, and even run-time concrete classes, it can generate byte-encoded delegate classes.
The delegated interface / class should meet the following conditions: a dynamic delegate can delegate at most one class, but can delegate multiple interfaces. This limitation comes from Java's single inheritance mode. A Java class has at most one parent class. Since the generated delegate class has the delegated class as its parent class, it is unreasonable to specify multiple delegated classes. If no delegated class is specified, the default parent class is Object.
Here is the code for the PHP reflection mechanism to implement the dynamic proxy:
It can be seen that his method is implemented through the proxy class FruitDelegator instead of the Fruit class.
Similarly, the following code works:
A cd class is designed, which includes mp3 playback mode and mp4 playback mode
Before improvement, to use the playback mode of the cd class, you need to determine which playback mode to choose in the instantiated class.
After the improvement, the playback mode is passed into the playList function as a parameter, and the corresponding method for playback can be found automatically.
1. Before improvement
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.