Benefits:
• It keeps state-specific behavior local and partitions behavior for different states.
• It makes any state transitions explicit.
Applicable Scenarios:
• The behavior of an object depends on its state and it must be able to change its behavior at runtime according on the new state.
• Operations have large, multipart conditional statements that depend on the state of the object.
博客介绍了对象状态行为的相关内容。其优势在于能将特定状态行为局部化,划分不同状态的行为,使状态转换更明确。适用场景包括对象行为依赖其状态且需在运行时根据新状态改变行为,以及操作有依赖对象状态的大型多部分条件语句。
146

被折叠的 条评论
为什么被折叠?



