Now look at Listing 8, which has the same logic for handling the robot's states, but this time puts the logic into the state pattern.
现在查看清单8,其中提供了相同的逻辑处理机器人的状态,但是这一次把逻辑放入状态模式。
For instance, with slight modification you can introduce the state pattern with some persistence to keep track of conversational state.
例如,只需稍作修改,就可以为state模式引入持久性,以跟踪会话状态。
One of the benefits of applying the state pattern is that it can resolve the if-statement situation difficulty shown in Figure 3 by isolating the various states.
使用State这个模式的一个好处是,它可以通过孤立各种状态来分解图3中if语句的情景。
The state pattern is a similar to the command pattern, but the intent is quite different.
状态模式类似于命令模式,但是意图截然不同。
The state pattern is a similar to the command pattern, but the intent is quite different.
状态模式类似于命令模式,但是意图截然不同。
应用推荐