(According to the msdn webcast courses)
Objects in different States often perform different actions.
Usually, we can use the switch... Case statement to solve the problem. However, if the state changes frequently, this must cause tight coupling between the object and the object. Of course, we should not deliberately adopt the design pattern to use the design pattern, because
In a single case, the adoption of the model may complicate the design. In the initial stage of the project, we recommend that you do not deliberately apply the model, but find the change point as needed and gradually reconstruct the design mode.
When the design mode is not used:
When a new state such as printing is added to a document, due to the tight coupling, the original Enumeration type and document class objects must be destroyed at the same time.
When the State mode is used:
In this mode, we only need to add a printingdocument class that inherits from stateddocument. You can assign a value to the document object in the stateddocument attribute during the call. At the same time, we can also predict to define the status switch in the stateddocument class.
<End>