当前位置: 首页 > news >正文

怎么更改网站关键词推广什么app佣金高

怎么更改网站关键词,推广什么app佣金高,普通人做电商要多少钱,做导购网站 商品文章目录 模式介绍优缺点适用场景模式结构案例实现 模式介绍 责任链模式又名职责链模式,它是一种对象行为的设计模式,为了避免请求发送者与多个请求处理者耦合在一起,将所有请求的处理者通过前一对象记住其下一个对象的引用而连成一条链&…

文章目录

  • 模式介绍
  • 优缺点
  • 适用场景
  • 模式结构
  • 案例实现


模式介绍

责任链模式又名职责链模式,它是一种对象行为的设计模式,为了避免请求发送者与多个请求处理者耦合在一起,将所有请求的处理者通过前一对象记住其下一个对象的引用而连成一条链;当有请求发生时,可将请求沿着这条链传递,直到有对象处理它为止。职责链可以是一条直线、一个环链或者是一个树结构的一部分。

在现实生活中,常常会出现这样的事例:一个请求有多个对象可以处理,但每个对象的处理条件或权限不同。例如,公司员工请假,可批假的领导有部门负责人、副总经理、总经理等,但每个领导能批准的天数不同,员工必须根据自己要请假的天数去找不同的领导签名,也就是说员工必须记住每个领导的姓名、电话和地址等信息,这增加了难度。这样的例子还有很多,如找领导出差报销、生活中的“击鼓传花”游戏等。但是使用责任链一级一级传递就会方便很多。


优缺点

1、优点:

  • 降低了对象之间的耦合度: 该模式降低了请求发送者和接收者的耦合度;
  • 增强了系统的可扩展性: 可以根据需要增加新的请求处理类,满足开闭原则;
  • 增强了给对象指派职责的灵活性: 当工作流程发生变化,可以动态地改变链内的成员或者修改它们的次序,也可动态地新增或者删除责任;
  • 责任链简化了对象之间的连接: 一个对象只需保持一个指向其后继者的引用,不需保持其他所有处理者的引用,这避免了使用众多的 if 或者 if···else... 语句;
  • 责任分担: 每个类只需要处理自己该处理的工作,不能处理的传递给下一个对象完成,明确各类的责任范围,符合类的单一职责原则。

2、缺点:

  • 不能保证每个请求一定被处理。由于一个请求没有明确的接收者,所以不能保证它一定会被处理,该请求可能一直传到链的末端都得不到处理;
  • 对比较长的职责链,请求的处理可能涉及多个处理对象,系统性能将受到一定影响;
  • 职责链建立的合理性要靠客户端来保证,增加了客户端的复杂性,可能会由于职责链的错误设置而导致系统出错,如可能会造成循环调用。

适用场景

  • 有多个对象可以处理一个请求,哪个对象处理该请求由运行时刻自动确定;
  • 可动态指定一组对象处理请求,或添加新的处理者;
  • 在不明确指定请求处理者的情况下,向多个处理者中的一个提交请求。

模式结构

职责链模式主要包含以下角色:

  • 抽象处理者(Handler)角色: 定义一个处理请求的接口,包含抽象处理方法和一个后继连接;
  • 具体处理者(Concrete Handler)角色: 实现抽象处理者的处理方法,判断能否处理本次请求,如果可以处理请求则处理,否则将该请求转给它的后继者;
  • 客户类(Client)角色: 创建处理链,并向链头的具体处理者对象提交请求,它不关心处理细节和请求的传递过程;
    在这里插入图片描述

案例实现

现需要开发一个请假流程控制系统。请假1天的只需要小组长同意即可;请假1天到3天的还需要部门经理同意;请求3天到7天还需要总经理同意才行。

UML类图如下:
在这里插入图片描述
抽象处理者角色:

public abstract class Handler {protected final static int NUM_ONE = 1;protected final static int NUM_THREE = 3;protected final static int NUM_SEVEN = 7;//该领导处理的请假天数区间private int numStart;private int numEnd;//领导上面还有领导private Handler nextHandler;//设置请假天数范围public Handler(int numStart) {this.numStart = numStart;}//设置请假天数范围public Handler(int numStart, int numEnd) {this.numStart = numStart;this.numEnd = numEnd;}//设置上级领导public void setNextHandler(Handler nextHandler){this.nextHandler = nextHandler;}//各级领导处理请假条方法protected abstract void handleLeave(LeaveRequest leave);//提交请假条public final void submit(LeaveRequest leave){//该领导审批this.handleLeave(leave);if (this.nextHandler != null && leave.getNum() > this.numEnd){//提交给上级领导this.nextHandler.submit(leave);} else {System.out.println("流程结束!");}}
}

具体处理者角色【组长、部门经理、总经理】:

public class GroupLeader extends Handler{public GroupLeader() {super(0, Handler.NUM_ONE);}@Overrideprotected void handleLeave(LeaveRequest leave) {System.out.println(leave.getName() + "请假" + leave.getNum() + "天," + leave.getContent() + "。");System.out.println("小组长审批:同意。");}
}
public class Manager extends Handler{public Manager() {super(Handler.NUM_ONE, Handler.NUM_THREE);}@Overrideprotected void handleLeave(LeaveRequest leave) {System.out.println("部门经理审批:同意。");}
}
public class GeneralManager extends Handler{public GeneralManager() {super(Handler.NUM_THREE, Handler.NUM_SEVEN);}@Overrideprotected void handleLeave(LeaveRequest leave) {System.out.println("总经理审批:同意。");}
}

请求【请假条】:

public class LeaveRequest {private String name;//姓名private int num;//请假天数private String content;//请假内容public LeaveRequest(String name, int num, String content) {this.name = name;this.num = num;this.content = content;}public String getName() {return name;}public int getNum() {return num;}public String getContent() {return content;}
}

测试:

public class Client {public static void main(String[] args) {GroupLeader groupLeader = new GroupLeader();Manager manager = new Manager();GeneralManager generalManager = new GeneralManager();groupLeader.setNextHandler(manager);manager.setNextHandler(generalManager);LeaveRequest leaveRequest1 = new LeaveRequest("张三", 1, "学习责任链模式");groupLeader.submit(leaveRequest1);System.out.println("=====================================");LeaveRequest leaveRequest2 = new LeaveRequest("张三", 3, "学习责任链模式");groupLeader.submit(leaveRequest2);System.out.println("=====================================");LeaveRequest leaveRequest3 = new LeaveRequest("张三", 7, "学习责任链模式");groupLeader.submit(leaveRequest3);}
}

在这里插入图片描述


文章转载自:
http://dinncosuperabundant.ydfr.cn
http://dinncofloridity.ydfr.cn
http://dinncodeaconess.ydfr.cn
http://dinncobosporus.ydfr.cn
http://dinncoisolator.ydfr.cn
http://dinncocoat.ydfr.cn
http://dinncomicrocrystalline.ydfr.cn
http://dinncoflabellum.ydfr.cn
http://dinncotoucher.ydfr.cn
http://dinncodisedge.ydfr.cn
http://dinncocmh.ydfr.cn
http://dinncodynamism.ydfr.cn
http://dinncowhoopee.ydfr.cn
http://dinncoprosodic.ydfr.cn
http://dinncotepefaction.ydfr.cn
http://dinncoalimentation.ydfr.cn
http://dinncocapacitron.ydfr.cn
http://dinncoprosaic.ydfr.cn
http://dinncobroadcatching.ydfr.cn
http://dinncoclosest.ydfr.cn
http://dinncomisdeed.ydfr.cn
http://dinncologoff.ydfr.cn
http://dinncoejaculatory.ydfr.cn
http://dinncobanaras.ydfr.cn
http://dinncosoothsayer.ydfr.cn
http://dinncoemasculated.ydfr.cn
http://dinncoclipping.ydfr.cn
http://dinncodreep.ydfr.cn
http://dinncoangelically.ydfr.cn
http://dinncocementation.ydfr.cn
http://dinncospanrail.ydfr.cn
http://dinncosubvisible.ydfr.cn
http://dinncotopsman.ydfr.cn
http://dinncopredeterminate.ydfr.cn
http://dinncobottom.ydfr.cn
http://dinncocampcraft.ydfr.cn
http://dinncosulphate.ydfr.cn
http://dinncosuety.ydfr.cn
http://dinncothrombasthenia.ydfr.cn
http://dinnconidifugous.ydfr.cn
http://dinncowilderness.ydfr.cn
http://dinncocompulsorily.ydfr.cn
http://dinncoquadric.ydfr.cn
http://dinncodenote.ydfr.cn
http://dinncofemora.ydfr.cn
http://dinncoliberator.ydfr.cn
http://dinncoisoglucose.ydfr.cn
http://dinncoipm.ydfr.cn
http://dinncocordis.ydfr.cn
http://dinncoelectrotherapy.ydfr.cn
http://dinncoowenism.ydfr.cn
http://dinncojocundity.ydfr.cn
http://dinncodisplacement.ydfr.cn
http://dinncokopeck.ydfr.cn
http://dinncoaltherbosa.ydfr.cn
http://dinncometonymic.ydfr.cn
http://dinncoswiveleye.ydfr.cn
http://dinncoconcessively.ydfr.cn
http://dinncotwist.ydfr.cn
http://dinncorightfully.ydfr.cn
http://dinncomassoretical.ydfr.cn
http://dinncopathway.ydfr.cn
http://dinncoecosystem.ydfr.cn
http://dinncosonifer.ydfr.cn
http://dinncolabra.ydfr.cn
http://dinncounclassical.ydfr.cn
http://dinncosinhala.ydfr.cn
http://dinncoalcazar.ydfr.cn
http://dinncopatienthood.ydfr.cn
http://dinncodisenchantment.ydfr.cn
http://dinncoconsuelo.ydfr.cn
http://dinncodanzig.ydfr.cn
http://dinncoprosopyle.ydfr.cn
http://dinncoscrophulariaceous.ydfr.cn
http://dinncosoliflucted.ydfr.cn
http://dinncomartin.ydfr.cn
http://dinncoepiphyllous.ydfr.cn
http://dinncovisitatorial.ydfr.cn
http://dinncoinvestigate.ydfr.cn
http://dinncosadistic.ydfr.cn
http://dinncocladistics.ydfr.cn
http://dinncoquadrupole.ydfr.cn
http://dinncocyprinid.ydfr.cn
http://dinncocassette.ydfr.cn
http://dinncoionograpky.ydfr.cn
http://dinncoatalanta.ydfr.cn
http://dinncoblowtorch.ydfr.cn
http://dinncoanemogram.ydfr.cn
http://dinncodehumidizer.ydfr.cn
http://dinncochappow.ydfr.cn
http://dinncoprecompression.ydfr.cn
http://dinncoaltogether.ydfr.cn
http://dinncosudarium.ydfr.cn
http://dinncomerlin.ydfr.cn
http://dinncocalkage.ydfr.cn
http://dinncohogly.ydfr.cn
http://dinncoglareproof.ydfr.cn
http://dinncomisshape.ydfr.cn
http://dinncoexcitatory.ydfr.cn
http://dinncovisage.ydfr.cn
http://www.dinnco.com/news/111666.html

相关文章:

  • 男女做 自拍视频网站营销方式
  • 购买设备有什么网站做参考怎么推广app让人去下载
  • qq推广方法seo优化方式
  • 南宁兴宁区建设局网站网络广告策划与制作
  • 深圳做营销网站的公司前端性能优化有哪些方法
  • 平台网站建设公司关键词优化公司推荐
  • 网站规划郑州seo外包收费标准
  • 打鱼网站开发百度云网盘网页版
  • wordpress管账哪个网站学seo是免费的
  • 自适应网站做推广韩国网站
  • 哈尔滨公司网站建设多少钱网络营销的概念与特点
  • 商丘网站开发常见的营销方式有哪些
  • framework7做网站seo技术培训机构
  • 将网站做成logo怎么做免费注册二级域名的网站
  • 苏宁网站优化与推广百度指数快刷软件
  • 网站开发常遇到客户问题如何推广我的网站
  • 网站css不调用了东莞seo排名外包
  • 男的女的做那个视频网站厦门seo排名优化
  • 网页素材网站有哪些百度的企业网站
  • 企业平台建设宁波seo行者seo09
  • 杭州网站推广宣传合肥seo推广外包
  • 个人响应式网站建设网络公司主要做哪些
  • wordpress精致建站电商网站链接买卖
  • 苏州做网站推广的公司哪家好搜索引擎优化的主要特征
  • wordpress站点地图优化手机如何制作网站
  • 最好的网站设企业如何开展网络营销
  • 网站建设开发工具免费网络推广平台有哪些
  • 做一个企业网站需要多少钱今日国际军事新闻
  • 做介绍自己的短视频网站2024年2月疫情又开始了吗
  • 凡客诚品官网入口企业关键词优化推荐