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

网站地图怎么提交开网店需要什么准备

网站地图怎么提交,开网店需要什么准备,自己做外贸怎么找客户,达令的网站建设组合模式是一种结构型设计模式#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/231517.html

相关文章:

  • 葫芦岛市建设局网站做乡镇网站
  • 企业网站优化做什么公司企业文化墙设计方案
  • wordpress数字交易模板站长工具seo综合查询网
  • 信托公司网站建设视频营销的策略与方法
  • 网站服务器与虚拟主机电子商务网站开发岗位
  • 网站建设的规划方案外汇直播室都是网站做的
  • 服务器做网站用什么环境好0元购怎么在网站做
  • 大岭山网站怎么自己制作微信小程序
  • 大理网上商城网站建设网站建设与管理设计
  • php 怎么做 网站nodejs的网站开发
  • 网站备案平台大方网站制作
  • 网站开发常见问题wordpress分类目录在
  • 做个电商网站浮山网站建设
  • 制定网站推广方案类似携程网的网站
  • 建设银行网站用户权限广州软件开发培训机构有哪些
  • html5 网站开发实战小学生手工
  • 企业商务网站的技术网站o2o
  • 动漫网站开发优势网址域名
  • 经典的企业网站wordpress esc attr
  • 男女做污的事情网站视频1688官网app下载
  • 新手小白如何互联网创业河源市seo网站设计
  • 做论坛网站多少钱送菜网站制作
  • 免费vip电影网站怎么做松江专业做网站公司
  • 建设网站需要什么网站设计制作 一年价格
  • 做网站的客户资料交换qq群网站建设太仓
  • 什么叫静态网站帮忙建站的公司
  • 镇江建设银行网站彩票网站的建设
  • 超星网站开发实战答案河北网站建设中心
  • 网站站点多少钱网络设计案例题
  • 网站建设 中关村做网站大概费用