The difference between static proxy mode (simple proxy mode) and strategy mode

The big difference in function between the simple proxy mode and the strategy mode is: in the 

simple proxy mode, the proxy class knows the behavior of the proxy class, because the proxy class and the proxy class implement the same interface, so the proxy class and the proxy class implement the same interface. The class structure is the same; 

in the strategy mode, the strategy container does not know the details of the internal strategy, because the container does not implement the same interface as the internal strategy, that is, the container and the internal strategy are just a simple combination, and the container only integrates the internal strategy. The behavior of the strategy is extracted and implemented uniformly.

 

The implementation methods of both are similar, that is, the implementation in the proxy class in the proxy mode is similar to the implementation in the policy container in the strategy mode, and the specific proxy class/specific policy class is passed as a parameter in a polymorphic way. enter.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325026737&siteId=291194637