Recognize status mode

xiaoxiao2021-03-06  37

Previously, the status mode was always packaged for each state, and now I know my understanding is coming.

The status mode is actually just abstracts the "status section" of an object. Therefore, it can easily reconstruct the code that does not use this mode. Because we do just add code, don't modify too many original code.

In addition, the efficiency of the status mode is also quite high, and it is not like some modes to sacrifice the efficiency for scalability.

The status mode is a bit like policy mode because it is inherent: in different states, the system automatically takes different strategies.

It is much more than the policy mode: this strategy is also responsible for the state of conversion. Therefore, the specific policy must hold the reference to the original object (in Java, it is the parameter transfer when using the function call to do this; C , I think the member variables of the virtual base class are more convenient).

Read the introduction of the book, it is not very clear, and then throws away the courses, painting the UML map to think, this is suddenly realized. This may be a very good "learning model" of learning design patterns :)

转载请注明原文地址:https://www.9cbs.com/read-72477.html

New Post(0)