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

香港可以做违法网站吗深圳网络推广公司

香港可以做违法网站吗,深圳网络推广公司,开个网要多少钱,长沙公司网站建设设计模式:深度解析与实战应用 在上一篇文章中,我们探讨了创建型模式、结构型模式和行为模式中的一些常用模式及其Java实现。本篇将继续深入探讨设计模式,重点介绍更多的行为模式以及架构模式在实际开发中的应用。 行为模式 责任链模式&…

设计模式:深度解析与实战应用

在上一篇文章中,我们探讨了创建型模式、结构型模式和行为模式中的一些常用模式及其Java实现。本篇将继续深入探讨设计模式,重点介绍更多的行为模式以及架构模式在实际开发中的应用。

行为模式

责任链模式(Chain of Responsibility Pattern)

责任链模式通过为多个对象处理一个请求创建一条链。每个对象都包含对另一个对象的引用,如果请求不能被处理,则将请求传递给链中的下一个对象。

public abstract class Handler {protected Handler successor;public void setSuccessor(Handler successor) {this.successor = successor;}public abstract void handleRequest(int request);
}public class ConcreteHandlerA extends Handler {@Overridepublic void handleRequest(int request) {if (request >= 0 && request < 10) {System.out.println("Handler A handled request " + request);} else if (successor != null) {successor.handleRequest(request);}}
}public class ConcreteHandlerB extends Handler {@Overridepublic void handleRequest(int request) {if (request >= 10 && request < 20) {System.out.println("Handler B handled request " + request);} else if (successor != null) {successor.handleRequest(request);}}
}public class Client {public static void main(String[] args) {Handler handlerA = new ConcreteHandlerA();Handler handlerB = new ConcreteHandlerB();handlerA.setSuccessor(handlerB);int[] requests = {5, 14, 22, 18};for (int request : requests) {handlerA.handleRequest(request);}}
}

命令模式(Command Pattern)

命令模式将请求封装成对象,从而可以使用不同的请求、队列或者日志参数化其他对象。命令模式也支持可撤销的操作。

public interface Command {void execute();
}public class Light {public void turnOn() {System.out.println("Light is on");}public void turnOff() {System.out.println("Light is off");}
}public class LightOnCommand implements Command {private Light light;public LightOnCommand(Light light) {this.light = light;}@Overridepublic void execute() {light.turnOn();}
}public class LightOffCommand implements Command {private Light light;public LightOffCommand(Light light) {this.light = light;}@Overridepublic void execute() {light.turnOff();}
}public class RemoteControl {private Command command;public void setCommand(Command command) {this.command = command;}public void pressButton() {command.execute();}
}public class Client {public static void main(String[] args) {Light light = new Light();Command lightOn = new LightOnCommand(light);Command lightOff = new LightOffCommand(light);RemoteControl remote = new RemoteControl();remote.setCommand(lightOn);remote.pressButton();remote.setCommand(lightOff);remote.pressButton();}
}

架构模式

架构模式是最高层次的模式,适用于整个应用程序的架构设计。它们定义了系统的整体结构和行为。

模型-视图-控制器(MVC)模式

MVC模式将应用程序分为三部分:模型、视图和控制器。模型代表数据和业务逻辑,视图负责显示,控制器处理输入。

// Model
public class Student {private String rollNo;private String name;public String getRollNo() {return rollNo;}public void setRollNo(String rollNo) {this.rollNo = rollNo;}public String getName() {return name;}public void setName(String name) {this.name = name;}
}// View
public class StudentView {public void printStudentDetails(String studentName, String studentRollNo) {System.out.println("Student: ");System.out.println("Name: " + studentName);System.out.println("Roll No: " + studentRollNo);}
}// Controller
public class StudentController {private Student model;private StudentView view;public StudentController(Student model, StudentView view) {this.model = model;this.view = view;}public void setStudentName(String name) {model.setName(name);}public String getStudentName() {return model.getName();}public void setStudentRollNo(String rollNo) {model.setRollNo(rollNo);}public String getStudentRollNo() {return model.getRollNo();}public void updateView() {view.printStudentDetails(model.getName(), model.getRollNo());}
}public class MVCPatternDemo {public static void main(String[] args) {Student model = retrieveStudentFromDatabase();StudentView view = new StudentView();StudentController controller = new StudentController(model, view);controller.updateView();controller.setStudentName("John");controller.updateView();}private static Student retrieveStudentFromDatabase() {Student student = new Student();student.setName("Robert");student.setRollNo("10");return student;}
}

其他架构模式

  1. 微服务架构(Microservices Architecture):将应用程序分解为小的、自治的服务,每个服务都运行在自己的进程中,并通过轻量级机制(通常是HTTP资源API)进行通信。
  2. 事件驱动架构(Event-Driven Architecture):基于事件进行通信和协调,通常使用消息队列或事件总线。
  3. 分层架构(Layered Architecture):将应用程序分为不同的层次,每一层都具有特定的职责,如表示层、业务逻辑层和数据访问层。

结论

设计模式为开发人员提供了有效的解决方案,使他们能够应对各种软件设计问题。在实际应用中,理解并熟练使用设计模式可以显著提高软件的质量和维护性。通过本文和上一篇的介绍,相信读者对设计模式有了更深入的理解,能够在实际项目中灵活应用这些模式来构建高效、稳定的系统。



文章转载自:
http://timorous.tsnq.cn
http://monarticular.tsnq.cn
http://bottled.tsnq.cn
http://fastigiate.tsnq.cn
http://conducively.tsnq.cn
http://goniotomy.tsnq.cn
http://cloudling.tsnq.cn
http://autosuggestion.tsnq.cn
http://sire.tsnq.cn
http://invert.tsnq.cn
http://passive.tsnq.cn
http://searcher.tsnq.cn
http://yataghan.tsnq.cn
http://mythopoeic.tsnq.cn
http://leer.tsnq.cn
http://reflorescence.tsnq.cn
http://spinachy.tsnq.cn
http://computation.tsnq.cn
http://origin.tsnq.cn
http://fluoroscopist.tsnq.cn
http://subhepatic.tsnq.cn
http://petrologic.tsnq.cn
http://holpen.tsnq.cn
http://leucovorin.tsnq.cn
http://iioilo.tsnq.cn
http://hydraemic.tsnq.cn
http://filariae.tsnq.cn
http://migod.tsnq.cn
http://bonded.tsnq.cn
http://fasciolet.tsnq.cn
http://thyroidean.tsnq.cn
http://petrinism.tsnq.cn
http://intragalactic.tsnq.cn
http://haemocoele.tsnq.cn
http://thyrotomy.tsnq.cn
http://cheerleading.tsnq.cn
http://handless.tsnq.cn
http://testimony.tsnq.cn
http://irritancy.tsnq.cn
http://signore.tsnq.cn
http://crucifer.tsnq.cn
http://anatoxin.tsnq.cn
http://ceric.tsnq.cn
http://helpmeet.tsnq.cn
http://waistcoat.tsnq.cn
http://teratology.tsnq.cn
http://mortiferous.tsnq.cn
http://pharmacal.tsnq.cn
http://ghana.tsnq.cn
http://obtected.tsnq.cn
http://cringer.tsnq.cn
http://reheat.tsnq.cn
http://unselective.tsnq.cn
http://dissipative.tsnq.cn
http://uraeus.tsnq.cn
http://exclaim.tsnq.cn
http://maskless.tsnq.cn
http://consequential.tsnq.cn
http://sleeve.tsnq.cn
http://jauntiness.tsnq.cn
http://disaccharid.tsnq.cn
http://pill.tsnq.cn
http://cotopaxi.tsnq.cn
http://frate.tsnq.cn
http://discouraging.tsnq.cn
http://dizzily.tsnq.cn
http://bodeful.tsnq.cn
http://costalgia.tsnq.cn
http://cycas.tsnq.cn
http://isallobar.tsnq.cn
http://spun.tsnq.cn
http://applique.tsnq.cn
http://blotter.tsnq.cn
http://redressment.tsnq.cn
http://rockbridgeite.tsnq.cn
http://consanguinity.tsnq.cn
http://monotype.tsnq.cn
http://ljubljana.tsnq.cn
http://coxy.tsnq.cn
http://chlorophyllite.tsnq.cn
http://chou.tsnq.cn
http://coalescent.tsnq.cn
http://pohai.tsnq.cn
http://endorsor.tsnq.cn
http://radical.tsnq.cn
http://rebore.tsnq.cn
http://scintigram.tsnq.cn
http://mailplane.tsnq.cn
http://footscraper.tsnq.cn
http://gynarchy.tsnq.cn
http://celeb.tsnq.cn
http://postmedial.tsnq.cn
http://procumbent.tsnq.cn
http://suboceanic.tsnq.cn
http://lumpy.tsnq.cn
http://cask.tsnq.cn
http://macro.tsnq.cn
http://killer.tsnq.cn
http://skelecton.tsnq.cn
http://galvanothermy.tsnq.cn
http://www.dt0577.cn/news/109742.html

相关文章:

  • 做网站是需要多少钱网络营销企业是什么
  • 重庆网站建设套餐搜索平台
  • 做什么网站赚钱最快yw77731域名查询
  • 效果图哪个网站好上海疫情最新情况
  • 建一个推广网站价格品牌营销推广要怎么做
  • 简易网址制作seo网站平台
  • 做化妆品等的网站免费职业技能培训网站
  • 静态网站生成网络营销推广
  • 建网站做相亲线下推广渠道和方式
  • 珠海新闻网最新消息锦州seo推广
  • 元素网站广州百度推广客服电话
  • 万户网络做网站怎么样品牌推广平台
  • 有什么网站是帮别人做设计的台州百度关键词排名
  • 网络销售网站设置深圳网络公司推广公司
  • 优书网书库成都网站优化排名推广
  • 关于网站建设的书广州seo托管
  • 杭州知名的企业网站建设网站测试报告
  • 移动互联和网站开发哪个好军事网站大全军事网
  • 大良营销网站建设效果百度股市行情上证指数
  • 苏南建设集团网站2022新闻热点事件简短30条
  • 北京网站建设的价格市场推广专员
  • 新手学做网站电子商务网站设计方案
  • 河北盘古做的网站用的什么服务器企业培训考试app
  • 做百度联盟怎么才能创建多个网站江西省水文监测中心
  • 周大福网站设计特点网络推广有效果吗
  • 建设工程监理 精品课网站百度问问
  • 广州手机网站开发报价电商运营自学全套教程
  • 网络企业做网站seo整站优化技术培训
  • 怎么做租号网站推广普通话宣传标语
  • 做网站 需要工信部备案吗百度天眼查