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

网站源码上传到空间以后怎么做免费在线设计平台

网站源码上传到空间以后怎么做,免费在线设计平台,wordpress 激活,网站主页模板图片组合模式是一种结构型设计模式#xff0c;主要用来将多个对象组织成树形结构以表示“部分-整体”的层次结构#xff0c;因此该模式也称为“部分-整体”模式。简言之#xff0c;组合模式就是用来将一组对象组合成树状结构#xff0c;并且能像使用独立对象一样使用它们。 Co…组合模式是一种结构型设计模式主要用来将多个对象组织成树形结构以表示“部分-整体”的层次结构因此该模式也称为“部分-整体”模式。简言之组合模式就是用来将一组对象组合成树状结构并且能像使用独立对象一样使用它们。 Composite is a structural design pattern that lets you organize multiple objects into a tree structure to represent the part whole relationship. In short, the composite pattern can be used to combine a group of objects into a tree structure and use them as independent objects. 结构设计 为实现组合模式首先需要创建一个可以组合多个对象的单一对象Component这个对象用来访问和管理其子对象并对外提供公共接口。然后定义没有子节点的对象Leaf基本对象和包含子对象的对象Composite组合对象。最后将这些对象组装到之前创建的对象上。这样外部Client就可通过Component调用公共接口。组合模式包含如下角色 Component组合对象为组合中的对象声明公共接口并提供默认实现。 Leaf叶节点对象叶节点最终会完成大部分的实际工作因为它们无法将工作指派给其他部分。 Compoiste组合也称容器包含叶节点或其他容器的单位。容器不知道其子项目所属的具体类 它只通过通用的组件接口与其子项目交互。 组合模式类图表示如下 注意 (1) 组合模式对基本对象和组合对象的使用具有一致性。外部代码调用Component公共接口时无需区别对待基本对象和组合对象(透明性)大多数情况下可以一致地处理它们。 伪代码实现 接下来将使用代码介绍下组合模式的实现。 // 1、Component组合对象为组合中的对象声明公共接口并提供默认实现。 public abstract class Component {private String name;protected ListComponent children new ArrayList();public Component(String componentName) {this.name componentName;}public void operation() {System.out.println(this.name);}public Component getChild(String componentName) {for (Component current : children) {if (current.name.equals(componentName)) {return current;}Component childComponent current.getChild(componentName);if (childComponent ! null) {return childComponent;}}return null;}public abstract void add(Component component);public abstract void remove(Component component); } // 2、Compoiste组合也称容器包含叶节点或其他容器的单位。容器不知道其子项目所属的具体类 // 它只通过通用的组件接口与其子项目交互。 public class Composite extends Component {public Composite(String componentName) {super(componentName);}Overridepublic void add(Component component) {this.children.add(component);}Overridepublic void remove(Component component) {this.children.remove(component);} } // 3、Leaf叶节点对象叶节点最终会完成大部分的实际工作因为它们无法将工作指派给其他部分。 public class Leaf extends Component {public Leaf(String componentName) {super(componentName);}Overridepublic void add(Component component) {throw new RuntimeException(叶节点不能添加子节点);}Overridepublic void remove(Component component) {throw new RuntimeException(叶节点不包含子节点无法移除子节点);} } // 4、客户端调用 public class CompositeClient {public void test() {Component root new Composite(root);root.add(new Leaf(Leaf A));Composite branch new Composite(Composite X);Leaf leafXa new Leaf(Leaf XA);branch.add(leafXa);branch.add(new Leaf(Leaf XB));branch.remove(leafXa);root.add(branch);Component leafXb root.getChild(Leaf XB);leafXb.operation();} }这里只介绍了基于透明性的设计与实现组合模式还支持一种基于安全性的设计与实现更多安全性相关知识可以执行搜索并学习。 适用场景 在以下情况下可以考虑使用组合模式 (1) 如果需要实现树状对象结构 可以考虑使用组合模式。 组合模式提供了两种共享公共接口的基本元素类型简单叶节点和复杂容器。容器中可以包含叶节点和其他容器。这使得开发者可以构建树状嵌套递归对象结构。 (2) 如果希望客户端代码以相同方式处理简单和复杂元素 可以使用该模式。 组合模式中定义的所有元素共用同一个接口。在这一接口的帮助下客户端不必在意其所使用的对象的具体类。 优缺点 组合模式最大特点是将多个对象组织成树形结构。组合模式有以下优点 (1) 可以利用多态和递归机制更方便地使用复杂树结构。 (2) 符合开闭原则。无需更改现有代码开发者就可以在应用中添加新元素使其成为对象树的一部分。 但是组合模式也存在以下缺点 (1) 对于功能差异较大的类 提供公共接口或许会有困难。在特定情况下开发者需要过度一般化组件接口使其变得令人难以理解。 参考 《设计模式可复用面向对象软件的基础》 Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides 著 李英军, 马晓星 等译 https://refactoringguru.cn/design-patterns/composite 组合模式 https://www.cnblogs.com/adamjwh/p/9033547.html 简说设计模式——组合模式 https://blog.csdn.net/ShuSheng0007/article/details/116378002 秒懂设计模式之组合模式Composite Pattern https://www.runoob.com/design-pattern/composite-pattern.html 组合模式
http://www.tj-hxxt.cn/news/216714.html

相关文章:

  • 制作网站商城vue可以做pc的网站
  • 调兵山网站建设iis部署网站浏览报404
  • 做网站怎么加入索引功能如何弄小程序
  • 网站优化怎么做 有什么技巧连云港做电商网站的公司
  • 网站上线后做什么wordpress知乎
  • 织梦网站怎么做备份做的网站如何全屏
  • 医疗整形网站怎么做内江市建设培训中心网站
  • 黑帽seo优化关键词seo自然排名优化
  • 网站上不去首页seo要怎么办自己制作的网页怎么发布
  • 福建省网站备案wordpress 开启xmlrpc
  • 沈阳学网站制作学校网站的建设意见
  • 南京做网站南京乐识最优it网站设计
  • 罗湖做网站58网站上的定位功能如何实现的
  • 栖霞建设网站wordpress群空间
  • 重庆专业网站搭建做视频网站推广
  • 阿里云建设网站教学电商小程序需要什么资质
  • 热点 做网站和营销 我只服他网站建设与管理淘宝
  • 湖北网站建设服务重庆无障碍网站建设
  • 网站公司谁家好潍坊网站建设一站式服务
  • 网络建站培训网站首页不收录
  • 哪里网站建设联系方式直播软件哪个好用
  • 网站建设的销售术语建模培训
  • 如何搭建自己得网站做网站主机选择
  • 自助建站免费申请个人网页企业怎么建设网站
  • 云和建设局网站高效的网站建设
  • 济南mip网站建设公司网络营销论文题目大全
  • 网站建设上海公司简单网站建设软件有哪些
  • 自己做个网站教程怎么在境外做网站
  • 网站建设的流程 步骤wordpress运行缓慢
  • 做单页网站vip视频网站如何做