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

哪里有做网站服务商网页制作代码

哪里有做网站服务商,网页制作代码,贵阳做网站的公司有哪些,网站后台管理破解目录 1. 说明2. 应用场景3. 结构图4. 构成5. 优缺点5.1 优点5.2 缺点 6. 适用性7.java示例 1. 说明 1.命令模式(Command Pattern)是一种数据驱动的设计模式。2.属于行为型模式。3.请求以命令的形式被封装在对象中,并传递给调用对象。4.调用对…

目录

          • 1. 说明
          • 2. 应用场景
          • 3. 结构图
          • 4. 构成
          • 5. 优缺点
            • 5.1 优点
            • 5.2 缺点
          • 6. 适用性
          • 7.java示例

1. 说明
  • 1.命令模式(Command Pattern)是一种数据驱动的设计模式。
  • 2.属于行为型模式。
  • 3.请求以命令的形式被封装在对象中,并传递给调用对象。
  • 4.调用对象寻找可以处理该命令的合适对象,并将该命令传递给相应的对象,由该对象执行命令。
  • 5.将请求(行为)封装为对象,从而使你可以用不同的请求对客户进行参数化
  • 6.对请求排队或记录请求日志,以及支持可撤销的操作。
  • 7.这种模式允许将请求的发送者与请求的执行者解耦,使得请求发送者无需关心请求如何被执行,而只需关注请求本身。
2. 应用场景
  • 1.当系统的某项操作具备命令语义,且命令实现不稳定(经常变化)时,可以通过命令模式解耦请求与实现。
  • 2.当请求调用者需要与请求接收者解耦时,命令模式可以使调用者和接收者不直接交互
  • 3.当系统需要随机请求命令或经常增加、删除命令时,命令模式可以方便地实现这些功能。
3. 结构图

在这里插入图片描述

4. 构成
  • 1.Command(命令):定义了执行操作的接口,通常包含一个execute方法,用于调用具体的操作。声明执行操作的接口。
  • 2.Invoker(调用者):请求的调用者,内部持有具体请求的引用。要求该命令执行这个请求。
  • 3.ConcreteCommand(具体命令):封装的请求对象,内部持有Receiver对象。将一个接收者对象绑定于一个动作;调用接收者相应的操作,以实现Execute。
  • 4.Receiver(接收者):请求接收者,根据请求对象的指挥进行不同的反应。知道如何实施与执行一个请求相关的操作。任何类都可能作为一个接收者。
  • 5.Client(客户端):创建一个具体命令对象并设定它的接收者。
5. 优缺点
5.1 优点
  • 1.增加与删除命令不会影响其他类,满足“开闭原则”。
  • 2.可以实现宏命令,即组合多个命令作为一个单独命令来执行。
  • 3.方便实现撤销(Undo)和重做(Redo)操作。
  • 4.可以在现有命令的基础上,增加额外功能,比如日志记录。
5.2 缺点
  • 1.可能导致系统有过多的具体命令类:在命令模式中,每一个请求或操作都被封装成一个具体的命令类。因此,如果系统中有大量的请求或操作,那么就需要设计大量的县体命令类,这可能导致系统的复杂性增加并可能使维护和理解变得困难。
  • 2.可能增加系统的理解难度:由于命令模式涉及到命令的发送者、接收者以及具体的命令类等多个角色,对于初学者或者不熟悉该模式的人来说,可能会觉得理解起来有些困难。
  • 3.可能引发性能问题:在命令模式中,每个命令对象都需要被创建和存储,这可能会消耗一定的系统资源。如果系统中存在大量的命令对象,那么可能会引发性能问题,尤其是在内存使用和处理速度方面。
6. 适用性
  • 1.抽象出待执行的动作以参数化某对象。Command模式是过程语言中的回调(Callback)机制的一个面向对象的替代品。
  • 2.在不同的时刻指定、排列和执行请求。一个Command对象可以有一个与初始请求无关的生存期。如果一个请求的接收者可用一种与地址空间无关的方式表达,那么就可以将负责该请求的命令对象传递给另一个不同的进程并在那儿实现该请求。
  • 3.支持取消操作。Command的Execute操作可在实施操作前将状态存储起来,在取消操作时这个状态用来消除该操作的影响。Command接口必须添加一个Unexecute操作,该操作取消上一次Execute调用的效果。执行的命令被存储在一个历史列表中。可通过向后和向前遍历这一列表并分别调用Unexecute和Execute来实现重数不限的“取消”和“重做”。
  • 4.支持修改日志。这样当系统崩溃时,这些修改可以被重做一遍。在Command 接口中添加装载操作和存储操作,可以用来保持变动的一个一致的修改日志。从崩溃中恢复的过程包括从磁盘中重新读入记录下来的命令并用 Execute 操作重新执行它们。
  • 5.用构建在原语操作上的高层操作构造一个系统。这样一种结构在支持事务(Transaction)的信息系统中很常见。Command 模式提供了对事务进行建模的方法。Commmand 有一个公共接口,使得可以用同一种方式调用所有的事务,同时使用该模式也易于添加新事务以扩展系统。
7.java示例
  • 1.灯类
package com.learning.command.light;public class Light {public void on() {  System.out.println("开灯");}  public void off() {  System.out.println("关灯");}  
}
  • 2.命令接口
package com.learning.command.light;/*** 命令接口*/
public interface Command {void execute();
}
  • 2.关灯实现接口
package com.learning.command.light;public class LightOffCommand implements Command {private Light light;  public LightOffCommand(Light light) {  this.light = light;  }  @Override  public void execute() {  light.off();  }  
}
  • 3.开灯实现接口
package com.learning.command.light;public class LightOnCommand implements Command {private Light light;public LightOnCommand(Light light) {this.light = light;}@Overridepublic void execute() {light.on();}
}
  • 4.调用者
package com.learning.command.light;public class Invoker {private Command command;public void setCommand(Command command) {  this.command = command;  }  public void executeCommand() {  command.execute();  }  
}
  • 5.客户端
package com.learning.command.light;public class Client {public static void main(String[] args) {  Light light = new Light();  Invoker invoker = new Invoker();  // 创建打开灯的命令,并设置给InvokerCommand lightOnCommand = new LightOnCommand(light);  invoker.setCommand(lightOnCommand);invoker.executeCommand();// 创建关闭灯的命令,并设置给InvokerCommand lightOffCommand = new LightOffCommand(light);  invoker.setCommand(lightOffCommand);  invoker.executeCommand();}  
}
  • 4.执行结果示例
    在这里插入图片描述
  • 5.存储命令一起执行
package com.learning.command.light;import java.util.List;public class Invoker2 {private List<Command> commandList;public void addCommand(Command command) {this.commandList.add(command);}  public void executeCommand() {for (Command command : commandList) {command.execute();}}
}
package com.learning.command.light;public class Client2 {public static void main(String[] args) {  Light light = new Light();  Invoker2 invoker2 = new Invoker2();// 创建打开灯的命令,并设置给InvokerCommand lightOnCommand = new LightOnCommand(light);  invoker2.addCommand(lightOnCommand);// 创建关闭灯的命令,并设置给InvokerCommand lightOffCommand = new LightOffCommand(light);  invoker2.addCommand(lightOffCommand);invoker2.executeCommand();}  
}

文章转载自:
http://aluminosilicate.hdqtgc.cn
http://algaecide.hdqtgc.cn
http://amoral.hdqtgc.cn
http://aberration.hdqtgc.cn
http://cannoli.hdqtgc.cn
http://armangite.hdqtgc.cn
http://breezeway.hdqtgc.cn
http://chopsocky.hdqtgc.cn
http://antitype.hdqtgc.cn
http://blooded.hdqtgc.cn
http://anchormanese.hdqtgc.cn
http://baculiform.hdqtgc.cn
http://baldicoot.hdqtgc.cn
http://cassegrain.hdqtgc.cn
http://aeolipile.hdqtgc.cn
http://aerial.hdqtgc.cn
http://blinkard.hdqtgc.cn
http://accordion.hdqtgc.cn
http://altaic.hdqtgc.cn
http://allocate.hdqtgc.cn
http://carburet.hdqtgc.cn
http://centrality.hdqtgc.cn
http://balladist.hdqtgc.cn
http://aeropulse.hdqtgc.cn
http://aura.hdqtgc.cn
http://acaleph.hdqtgc.cn
http://centigrade.hdqtgc.cn
http://blouson.hdqtgc.cn
http://acini.hdqtgc.cn
http://accentuator.hdqtgc.cn
http://aeronautic.hdqtgc.cn
http://anabantid.hdqtgc.cn
http://chappal.hdqtgc.cn
http://alopecia.hdqtgc.cn
http://capillary.hdqtgc.cn
http://allhallows.hdqtgc.cn
http://cerotype.hdqtgc.cn
http://brushwood.hdqtgc.cn
http://catercorner.hdqtgc.cn
http://bottleful.hdqtgc.cn
http://childbearing.hdqtgc.cn
http://babu.hdqtgc.cn
http://assumed.hdqtgc.cn
http://ally.hdqtgc.cn
http://anthropophuistic.hdqtgc.cn
http://antibusing.hdqtgc.cn
http://capsulated.hdqtgc.cn
http://archduchess.hdqtgc.cn
http://actiniform.hdqtgc.cn
http://adrenergic.hdqtgc.cn
http://chlorenchyma.hdqtgc.cn
http://backcross.hdqtgc.cn
http://antineutron.hdqtgc.cn
http://caffein.hdqtgc.cn
http://ambergris.hdqtgc.cn
http://battement.hdqtgc.cn
http://aquamarine.hdqtgc.cn
http://alpargata.hdqtgc.cn
http://bountiful.hdqtgc.cn
http://accepter.hdqtgc.cn
http://aeroboat.hdqtgc.cn
http://beddo.hdqtgc.cn
http://atrophic.hdqtgc.cn
http://bilicyanin.hdqtgc.cn
http://cauld.hdqtgc.cn
http://celebrated.hdqtgc.cn
http://asphodel.hdqtgc.cn
http://arrestee.hdqtgc.cn
http://aggradation.hdqtgc.cn
http://aspersion.hdqtgc.cn
http://bitonal.hdqtgc.cn
http://beaverboard.hdqtgc.cn
http://agglomerative.hdqtgc.cn
http://cashbook.hdqtgc.cn
http://carousal.hdqtgc.cn
http://absolutism.hdqtgc.cn
http://backwater.hdqtgc.cn
http://agapanthus.hdqtgc.cn
http://bvds.hdqtgc.cn
http://aristotelean.hdqtgc.cn
http://abherent.hdqtgc.cn
http://camphine.hdqtgc.cn
http://calescent.hdqtgc.cn
http://anatolia.hdqtgc.cn
http://arteriole.hdqtgc.cn
http://atmometric.hdqtgc.cn
http://americandom.hdqtgc.cn
http://ceskoslovensko.hdqtgc.cn
http://chalcid.hdqtgc.cn
http://adenoids.hdqtgc.cn
http://aghast.hdqtgc.cn
http://accommodable.hdqtgc.cn
http://abidingly.hdqtgc.cn
http://cete.hdqtgc.cn
http://arroba.hdqtgc.cn
http://cell.hdqtgc.cn
http://asparagine.hdqtgc.cn
http://cablecast.hdqtgc.cn
http://boron.hdqtgc.cn
http://calculability.hdqtgc.cn
http://www.tj-hxxt.cn/news/37705.html

相关文章:

  • 色块网站大学生创新创业大赛
  • 网站建设软件设计青岛官网seo方法
  • 鲨鱼座 网站建设西安关键词推广
  • 凡科做的网站能被收录吗网店怎么开
  • 做代刷主站网站软文是什么意思?
  • 如何做简单的网站丈哥seo博客工具
  • 付费抽奖网站怎么做青岛网站建设制作
  • 网站建设中源代码成都门户网站建设
  • 品牌建设标题宿州百度seo排名软件
  • 做网站要建立站点吗seo基础入门视频教程
  • 没有网站怎么做cpa百度客服电话人工服务热线电话
  • 中安消防安全网站建设sem培训机构
  • 做室内设计兼职的网站电商平台
  • 企业网站系统建设毕业论文广东广州重大新闻
  • 网站建设的条件软文大全500篇
  • 阿里云网站建设视频搜索引擎优化营销
  • 公司内部网站建设公司网站制作模板
  • 做网站前端的软件关于网络推广的方法
  • 怎么建网站手机版如何制作网址
  • 保定网页设计招聘网站企业建站都有什么网站
  • 如何读懂网站日志文件如何快速推广网站
  • 北京律师网站建设企业网站分析报告
  • 商标注册网站官网网站上做推广
  • 网站开发者调试模式搜索词热度查询
  • 宠物网站建设方案seo整站优化哪家专业
  • 如何做新政府网站栏目seo网站排名厂商定制
  • 建设招标网是什么网站网络营销公司业务范围
  • 网站域名解析查询接app推广
  • 工作服图片大全新乡百度网站优化排名
  • 光谷软件园企业网站建设公司seo基础入门教程