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

找国外客户的网站网站开发和编程的联系

找国外客户的网站,网站开发和编程的联系,扬州网站建设myvodo,wordpress图片抓取插件1 组合模式: 整体-部分模式,它是一种将对象组合成树状层次结构的模式,用来表示整体和部分的关系,使用户对单个对象和组合对象具有一致的访问性,属于结构型设计模式 1.1 特点: 组合模式使得客户端代码可以一致的处理单个对象和组合对象更容易在组合体内加入新的对象,客户端不…

1 组合模式:

整体-部分模式,它是一种将对象组合成树状层次结构的模式,用来表示整体和部分的关系,使用户对单个对象和组合对象具有一致的访问性,属于结构型设计模式

1.1 特点:

  1. 组合模式使得客户端代码可以一致的处理单个对象和组合对象
  2. 更容易在组合体内加入新的对象,客户端不会因为加入新的对象而改变原代码,满足''开闭原则''

1.2 缺点:

  1. 设计较复杂,客户端需要花更多的时间理清类之间的关系
  2. 不容易限制容器中的构建
  3. 不容易用继承的方法来增加构件的新功能 

1.3 结构:

  1. 抽象构件角色:
  2. 树叶构件角色:
  3. 树枝构件角色/中间构件: 

1.4 组合模式分为透明式的组合模式和安全式的组合模式。 

  1. 透明式:抽象构件声明了所有子类中的全部方法,客户端无需区别树叶对象和树枝对象
  2. 安全式:将管理子构件的方法移到树枝构件中,抽象构件和树叶构件没有对子对象的管理方法

1.5 代码实现

透明模式

public class CompositePattern {public static void main(String[] args) {Component c0 = new Composite();Component c1 = new Composite();Component leaf1 = new Leaf("1");Component leaf2 = new Leaf("2");Component leaf3 = new Leaf("3");c0.add(leaf1);c0.add(c1);c1.add(leaf2);c1.add(leaf3);c0.operation();}
}
//抽象构件
interface Component {public void add(Component c);public void remove(Component c);public Component getChild(int i);public void operation();
}
//树叶构件
class Leaf implements Component {private String name;public Leaf(String name) {this.name = name;}public void add(Component c) {}public void remove(Component c) {}public Component getChild(int i) {return null;}public void operation() {System.out.println("树叶" + name + ":被访问!");}
}
//树枝构件
class Composite implements Component {private ArrayList<Component> children = new ArrayList<Component>();public void add(Component c) {children.add(c);}public void remove(Component c) {children.remove(c);}public Component getChild(int i) {return children.get(i);}public void operation() {for (Object obj : children) {((Component) obj).operation();}}
}
树叶1:被访问!
树叶2:被访问!
树叶3:被访问!

安全模式

interface Component {public void operation();
}
public class CompositePattern {public static void main(String[] args) {Composite c0 = new Composite();Composite c1 = new Composite();Component leaf1 = new Leaf("1");Component leaf2 = new Leaf("2");Component leaf3 = new Leaf("3");c0.add(leaf1);c0.add(c1);c1.add(leaf2);c1.add(leaf3);c0.operation();}
}

http://www.yayakq.cn/news/588722/

相关文章:

  • 工艺品商城网站建设上海网站建设服务站霸网络
  • 阜阳h5网站建设北京市建筑工程信息交易网
  • 做化工哪个网站好家居网站建设费用
  • 网站开发支付模块自己在本地建的网站 别人怎么访问教程
  • 做网站温州网站优化查询代码
  • 扁平化中文网站模板下载杭州小程序开发
  • 做网站时的注册权起到什么作用企业网站建设cms系统
  • 面试网站建设的问题6凡科网建站教程
  • 成都网站外包优化网站界面美观度
  • 扒完网站代码之后怎么做模板怎么样注册自己的网站
  • 旅游公司网站制作有哪些网站可以做简历
  • 网站安全狗 拦截301阳西哪里有做网站
  • 公司网站对比那几点优势做前端常用的网站及软件
  • 北京企业网站设计制作宜阳网站建设
  • 淄博专业网站建设公司好看的商标logo设计
  • 找南阳建立网站的公司装修公司网站源代码
  • wordpress minfy常州seo收费
  • dw制作网站淘宝网淘我喜欢
  • 网站建设mfdos视频直播网站
  • 如何利用国外网站开发客户卖链接的网站
  • 怎么选择做网站的公司建设网站业务竞争大
  • html5手机企业网站模板莞城区仿做网站
  • 大数据平台建站建设网站的相关技术指标
  • 做守望先锋h的网站wordpress付费主题
  • 基于php技术的个人网站设计北京app制作多少钱
  • js网站源码下载北京房产网官网
  • 英文网站推荐个人养老保险账户余额查询
  • 京东网站建设目的在线制图网
  • 免费做网络推广aso应用商店优化
  • 中山市做网站的公司注册公司在哪里注册