《JAVA设计模式》之状态模式(State)
在阎宏博士的《JAVA与模式》一书中开头是这样描述状态(State)模式的:
状态模式,又称状态对象模式(Pattern of Objects for States),状态模式是对象的行为模式。
状态模式允许一个对象在其内部状态改变的时候改变其行为。这个对象看上去就像是改变了它的类一样。
状态模式的结构
用一句话来表述,状态模式把所研究的对象的行为包装在不同的状态对象里,每一个状态对象都属于一个抽象状态类的一个子类。状态模式的意图是让一个对象在其内部状态改变的时候,其行为也随之改变。状态模式的示意性类图如下所示:
状态模式所涉及到的角色有:
● 环境(Context)角色,也成上下文:定义客户端所感兴趣的接口,并且保留一个具体状态类的实例。这个具体状态类的实例给出此环境对象的现有状态。
● 抽象状态(State)角色:定义一个接口,用以封装环境(Context)对象的一个特定的状态所对应的行为。
● 具体状态(ConcreteState)角色:每一个具体状态类都实现了环境(Context)的一个状态所对应的行为。
源代码
环境角色类
public class Context {
//持有一个State类型的对象实例
private State state; public void setState(State state) {
this.state = state;
}
/**
* 用户感兴趣的接口方法
*/
public void request(String sampleParameter) {
//转调state来处理
state.handle(sampleParameter);
}
}
抽象状态类
public interface State {
/**
* 状态对应的处理
*/
public void handle(String sampleParameter);
}
具体状态类
public class ConcreteStateA implements State { @Override
public void handle(String sampleParameter) { System.out.println("ConcreteStateA handle :" + sampleParameter);
} }
public class ConcreteStateB implements State { @Override
public void handle(String sampleParameter) { System.out.println("ConcreteStateB handle :" + sampleParameter);
} }
客户端类
public class Client { public static void main(String[] args){
//创建状态
State state = new ConcreteStateB();
//创建环境
Context context = new Context();
//将状态设置到环境中
context.setState(state);
//请求
context.request("test");
}
}
从上面可以看出,环境类Context的行为request()是委派给某一个具体状态类的。通过使用多态性原则,可以动态改变环境类Context的属性State的内容,使其从指向一个具体状态类变换到指向另一个具体状态类,从而使环境类的行为request()由不同的具体状态类来执行。
使用场景
考虑一个在线投票系统的应用,要实现控制同一个用户只能投一票,如果一个用户反复投票,而且投票次数超过5次,则判定为恶意刷票,要取消该用户投票的资格,当然同时也要取消他所投的票;如果一个用户的投票次数超过8次,将进入黑名单,禁止再登录和使用系统。
要使用状态模式实现,首先需要把投票过程的各种状态定义出来,根据以上描述大致分为四种状态:正常投票、反复投票、恶意刷票、进入黑名单。然后创建一个投票管理对象(相当于Context)。
系统的结构图如下所示:
源代码
抽象状态类
public interface VoteState {
/**
* 处理状态对应的行为
* @param user 投票人
* @param voteItem 投票项
* @param voteManager 投票上下文,用来在实现状态对应的功能处理的时候,
* 可以回调上下文的数据
*/
public void vote(String user,String voteItem,VoteManager voteManager);
}
具体状态类——正常投票
public class NormalVoteState implements VoteState { @Override
public void vote(String user, String voteItem, VoteManager voteManager) {
//正常投票,记录到投票记录中
voteManager.getMapVote().put(user, voteItem);
System.out.println("恭喜投票成功");
} }
具体状态类——重复投票
public class RepeatVoteState implements VoteState { @Override
public void vote(String user, String voteItem, VoteManager voteManager) {
//重复投票,暂时不做处理
System.out.println("请不要重复投票");
} }
具体状态类——恶意刷票
public class SpiteVoteState implements VoteState { @Override
public void vote(String user, String voteItem, VoteManager voteManager) {
// 恶意投票,取消用户的投票资格,并取消投票记录
String str = voteManager.getMapVote().get(user);
if(str != null){
voteManager.getMapVote().remove(user);
}
System.out.println("你有恶意刷屏行为,取消投票资格");
} }
具体状态类——黑名单
public class BlackVoteState implements VoteState { @Override
public void vote(String user, String voteItem, VoteManager voteManager) {
//记录黑名单中,禁止登录系统
System.out.println("进入黑名单,将禁止登录和使用本系统");
} }
环境类
public class VoteManager {
//持有状体处理对象
private VoteState state = null;
//记录用户投票的结果,Map<String,String>对应Map<用户名称,投票的选项>
private Map<String,String> mapVote = new HashMap<String,String>();
//记录用户投票次数,Map<String,Integer>对应Map<用户名称,投票的次数>
private Map<String,Integer> mapVoteCount = new HashMap<String,Integer>();
/**
* 获取用户投票结果的Map
*/
public Map<String, String> getMapVote() {
return mapVote;
}
/**
* 投票
* @param user 投票人
* @param voteItem 投票的选项
*/
public void vote(String user,String voteItem){
//1.为该用户增加投票次数
//从记录中取出该用户已有的投票次数
Integer oldVoteCount = mapVoteCount.get(user);
if(oldVoteCount == null){
oldVoteCount = 0;
}
oldVoteCount += 1;
mapVoteCount.put(user, oldVoteCount);
//2.判断该用户的投票类型,就相当于判断对应的状态
//到底是正常投票、重复投票、恶意投票还是上黑名单的状态
if(oldVoteCount == 1){
state = new NormalVoteState();
}
else if(oldVoteCount > 1 && oldVoteCount < 5){
state = new RepeatVoteState();
}
else if(oldVoteCount >= 5 && oldVoteCount <8){
state = new SpiteVoteState();
}
else if(oldVoteCount > 8){
state = new BlackVoteState();
}
//然后转调状态对象来进行相应的操作
state.vote(user, voteItem, this);
}
}
客户端类
public class Client { public static void main(String[] args) { VoteManager vm = new VoteManager();
for(int i=0;i<9;i++){
vm.vote("u1","A");
}
} }
运行结果如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABD8AAADqCAIAAAAqF3mWAAAgAElEQVR4nO3df3Ac5Z3ncf2dvdt/ruq2auuqUle5uiNQtbVsVlw2u5etq9vljr1aFhInQBJgYrwgAzFGBkcJJij8kGUgtjCHLX7ZchZsYeFYtrExOMYCG/8AYhtsEUOIf2AbbMmSx5IsjzSS+v5oadTdz/N8n6d7fmjGfr9qCkbdTz/9PE+3Rs9nenpclQ7r7OxsaWlpaWlJX3ou+o5f9B1MJnfOe5eSlgmdnZ1TfQSmBr8OAACUM9NEpSr4gz+NK2GryshF3/GLvoPJ+Of8VEeJqXSJxxh+LwCg2FavXj1z5sxp8c2cOXP16tUFrASVSJ2iTKYXostF7KLvYDL+OT+GsbGxsbFLNsPw2wGg0j366KPnz5+f6lbotba2Tp8+feHChS/Et3Dhwptuuqm1tbUglfjtKeexgklkfjKeXiLRpaU51dJ0Y0tzqqW5pqWlrrWlsbW1ubW9tbV9c+vmjvaO/e0dh0rd8KK56OcuwQ6uf/wvtY+pa92UIbpoEWAAYEo0NTW2tkZfi1pbW5qaGq3byjPyXRvv1T7ybbGbmpqapqamlStXvhbf66+/vnDhwpqamoJU4jJWKFvB+YkhvTTdu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n854nnd42T/tmX+l/zi87J88z9uy42DuWoT5CkzFuOinLJEOPjT7fzxwz7fnzf72Mw//w8pF12x67p+Xz/jK8hlfWT7jT5bP+JPs4ceGDty+/F//ZKpaWzJ+ejmvuHrOmitubLrihkXj/71h0RU3NF1+Q9MVNzRdcUPT1XPWqJtcsrQB5vTHcyLRZWzgV033XBvnM2NT46J/KQBg0mHjWI82WviRw70xLpdx1K3kGXlz81ORx/r1a44c+eN11113zz331NbW+nftz5o161/+5V9Mlfym4aujfXtOfvhM3Q//Q90P/8PJD58Z+WLZbxq+Ojo2Njo2Nn1e676ebGZ4NDM8dtu80FWmSPCIxA81bAQFvzE5/0pcxiqdTjc91/rukYHMmHdhzMuMeZnRif9OPHnquVcsR3FCiS+8pNPppx7+0cf93vCoNzzqDY952bGx0ZGz3ukV3unlY17XyNhwdtQbHvOeetjpvpdyY08vLo/GphiXQcvTRT9lce/g86mvDB24/fnUV4ranjLhp5cB5Md/8Q1mmK6jL/kfGMtFl+FPHyz/6JK+BF4KAFSKBJdxkv378bW1tddee63/nWP33nvvddddd++995oKtz3y1fTvF46ceO7Q1p8c2vqTkRPPnf+0se2Rr65586PmV3b94uk3bqlrzT2CG6rBI3LNRAgex48fP378uDa9JKjEcawan/mN9RF3qEtmyYJ/XbLgX59ffOeud1cPHF3snX7B637l9Mn3315975IF/zr/F6ncY6pbmoQlvVw6LvqOx0ovl0h0SZNeCkq+DaZSXPQvBQAqSNzLOMnSSyz+XfuRx7vtD1o3rKmpWbNmzccff/xFfH78qKmpKUglJRsrFAnpZdxF3/GLvoPJ+OmlHwWiXoSpOPymAKhc5Twjb21tveuuu955553j8X300Uf3339/a2trQSrx21POYwUZ6WXcRd/xi76DyfjppQ8FlfsgbyXGGH5TAKBIVq1adccdd0yL74477li1alUBK0FFI72Mu+g7ftF3MBnSS1FVYozhNwUAgHKmSS/ApeYcimyqjzAAALh4RNNL6SMUAAAAAFiRXgAAAABUBtILAAAAgMpAegEAAABQGUgvAAAAACpDeaSX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xY8u999/f0tLC+kFAAAAgMpPL3Pnzl24cKEfYKYgvfjRZc6cOQsWLNiwYQPpBQAAAIAql16efvrpZcuWdXd39/T0lDq9dHV1PfDAAw899NCKFSu2bNlCegEAAACg8tNLXV1dS0vL5s2b33zzze7u7qm59rJ48eLVq1d3dHSQXgAAAACo/PTy8MMPb9q06b333puaay+5+15WrVq1Y8cO0gsAAAAAlZ9eli5dun379im77yX4nWPbtm0jvQAAAABQ+ell9erVU/ydY8EAw7/3AgAAAEDVWz7/3otsSkYHAAAAQPmIZIQSpZezAAAAAJCfYHQpYno5F1/iRgAAAACoUNaYEIwuxUovXfGdBgAAAHCJSRAcCp9eAAAAAKCskF4AAAAAVIZcWvn/4NZPzh46kzkAAAAASUVORK5CYII=" alt="" />
从上面的示例可以看出,状态的转换基本上都是内部行为,主要在状态模式内部来维护。比如对于投票的人员,任何时候他的操作都是投票,但是投票管理对象的处理却不一定一样,会根据投票的次数来判断状态,然后根据状态去选择不同的处理。
认识状态模式
● 状态和行为
所谓对象的状态,通常指的就是对象实例的属性的值;而行为指的就是对象的功能,再具体点说,行为大多可以对应到方法上。
状态模式的功能就是分离状态的行为,通过维护状态的变化,来调用不同状态对应的不同功能。也就是说,状态和行为是相关联的,它们的关系可以描述为:状态决定行为。
由于状态是在运行期被改变的,因此行为也会在运行期根据状态的改变而改变。
● 行为的平行性
注意平行线而不是平等性。所谓平行性指的是各个状态的行为所处的层次是一样的,相互独立的、没有关联的,是根据不同的状态来决定到底走平行线的哪一条。行为是不同的,当然对应的实现也是不同的,相互之间是不可替换的。
而平等性强调的是可替换性,大家是同一行为的不同描述或实现,因此在同一个行为发生的时候,可以根据条件挑选任意一个实现来进行相应的处理。
大家可能会发现状态模式的结构和策略模式的结构完全一样,但是,它们的目的、实现、本质却是完全不一样的。还有行为之间的特性也是状态模式和策略模式一个很重要的区别,状态模式的行为是平行性的,不可相互替换的;而策略模式的行为是平等性的,是可以相互替换的。
● 环境和状态处理对象
在状态模式中,环境(Context)是持有状态的对象,但是环境(Context)自身并不处理跟状态相关的行为,而是把处理状态的功能委托给了状态对应的状态处理类来处理。
在具体的状态处理类中经常需要获取环境(Context)自身的数据,甚至在必要的时候会回调环境(Context)的方法,因此,通常将环境(Context)自身当作一个参数传递给具体的状态处理类。
客户端一般只和环境(Context)交互。客户端可以用状态对象来配置一个环境(Context),一旦配置完毕,就不再需要和状态对象打交道了。客户端通常不负责运行期间状态的维护,也不负责决定后续到底使用哪一个具体的状态处理对象。
原文地址:《JAVA与模式》之状态模式
《JAVA设计模式》之状态模式(State)的更多相关文章
- 折腾Java设计模式之状态模式
原文地址 折腾Java设计模式之状态模式 状态模式 在状态模式(State Pattern)中,类的行为是基于它的状态改变的.这种类型的设计模式属于行为型模式.在状态模式中,我们创建表示各种状态的对象 ...
- 【转】设计模式 ( 十七) 状态模式State(对象行为型)
设计模式 ( 十七) 状态模式State(对象行为型) 1.概述 在软件开发过程中,应用程序可能会根据不同的情况作出不同的处理.最直接的解决方案是将这些所有可能发生的情况全都考虑到.然后使用if... ...
- 设计模式 ( 十七) 状态模式State(对象行为型)
设计模式 ( 十七) 状态模式State(对象行为型) 1.概述 在软件开发过程中,应用程序可能会根据不同的情况作出不同的处理.最直接的解决方案是将这些所有可能发生的情况全都考虑到.然后使用if... ...
- 乐在其中设计模式(C#) - 状态模式(State Pattern)
原文:乐在其中设计模式(C#) - 状态模式(State Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 状态模式(State Pattern) 作者:webabcd 介绍 允 ...
- 北风设计模式课程---状态模式State(对象行为型)
北风设计模式课程---状态模式State(对象行为型) 一.总结 一句话总结: 状态模式 具体状态的行为在具体的状态类中就解决,不用交给外部做判断.实质是将多条件判断弄成了多个类,在不同的类中做判断 ...
- 二十四种设计模式:状态模式(State Pattern)
状态模式(State Pattern) 介绍允许一个对象在其内部状态改变时改变它的行为.对象看起来似乎修改了它所属的类. 示例有一个Message实体类,对它的操作有Insert()和Get()方法, ...
- 设计模式2——状态模式State
参考链接: 设计模式之状态模式:https://www.cnblogs.com/haoerlv/p/7777789.html 设计模式系列之状态模式:https://www.jianshu.com/p ...
- 设计模式之 -- 状态模式(State)
状态模式允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类.当控制一个对象的状态转换条件分支语句(if...else或switch...case)过于复杂时,可以此模式将状态的判断逻辑 ...
- [设计模式] 20 状态模式 State Pattern
在GOF的<设计模式:可复用面向对象软件的基础>一书中对状态模式是这样说的:允许一个对象在其内部状态改变时改变它的行为.对象看起来似乎修改了它的类.状态模式的重点在于状态转换,很多时候,对 ...
- JAVA设计模式:状态模式
声明:转载请说明来源:http://www.cnblogs.com/pony1223/p/7518226.html 一.引出状态模式 假设我们现在有一个糖果机项目,那么我们知道正常一般糖果机提供给用户 ...
随机推荐
- django实例收集
django笔记(一)(模板渲染变量.字典.for循环.索引.条件语句) django笔记(二) django环境准备与笔记(三) django笔记(四) django笔记(五) Views的补充 w ...
- Vue动态注册异步组件(非同一个工程的组件)
前言:最近在掘金逛的时候,无意中看到前滴滴前端架构黄轶大佬,看到了大佬分享的一篇博客滴滴 webapp 5.0 Vue 2.0 重构经验分享 ,对于其中第5个问题(异步加载的业务线组件,如何动态注册? ...
- Python之列表、元组、字典、集合及字符串的详细使用
1.列表 列表相当与C++中的数组,是有序的项目, 通过索引进行查找,但使用起来却方便很多,具体的操作看代码,自己实践一次就非常简单了. 注:列表一般用中括号“[ ]” #列表(数组) name_li ...
- python基础--4 元祖
#元组,元素不可被修改,不能被增加或者删除 #tuple,有序 tu=(11,22,33,44,55,33) #count 获取指定元素在元祖中出现的次数 print(tu.count(33)) #i ...
- [Tvvj1391]走廊泼水节(最小生成树)
[Tvvj1391]走廊泼水节 Description 给定一棵N个节点的树,要求增加若干条边,把这棵树扩充为完全图,并满足图的唯一最小生成树仍然是这棵树.求增加的边的权值总和最小是多少. 完全图:完 ...
- 新特性2-lambda表达式
最近几天学习了一下lambda表达式,看了不少博客,感觉有一篇博客总结的一句话总结的很好:lambda表达式是一段可以传递的代码,它的核心思想是将面向对象中的传递数据变成传递行为.其实以前也有传递行为 ...
- django 的保护机制
- centos上部署flask项目之环境配置-MySQL的安装
1.添加mysql 的yum源 wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm' rpm ...
- 关于python3 使用pycharm+unittest+html+HTMLTestRunner 测试用例运行正常,但却不能生成测试报告的解决方法
关于python3 使用pycharm+unittest+html+HTMLTestRunner 测试用例运行正常,但却不能生成测试报告的解决方法 这个问题我也遇到过,以下是解决办法 该方法适用于 ...
- shell第一个脚本
mkdir 创建目录touch 创建空文件 chmod +x ./test.sh #使脚本具有执行权限