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

网站建设外包公司怎么样网络优化的三个方法

网站建设外包公司怎么样,网络优化的三个方法,人工智能软件,dw怎样做收藏本网站目录 介绍 实现 优缺点 装饰模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其结构。这种类型的设计模式属于结构型模式,它是作为现有类的一个包装。这种模式创建了一个装饰类,用来包装原有…

目录

介绍

实现

优缺点


装饰模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其结构。这种类型的设计模式属于结构型模式,它是作为现有类的一个包装。这种模式创建了一个装饰类,用来包装原有的类,并在保持类方法签名完整性的前提下,提供了额外的功能。

介绍

意图:动态地给一个对象添加一些额外的职责。就增加功能来说,装饰模式相比生成子类更灵活。

主要解决:我们扩展一个类常使用继承方式实现,由于继承为类引入静态特征,并且随着扩展功能的增多,子类会越来越膨胀。

如何使用:在不想增加很多子类的情况下扩展。

如何解决:将具体功能职责划分,同时继承装饰者模式。

关键代码:1. Component 类充当抽象角色,不应该具体实现。2. 修饰类引用合继承 Component 类,具体扩展类重写父类方法。

使用场景:1. 扩展一个类的功能。2. 动态增加功能,动态撤销。

实现

创建一个 Shape 接口合实现了 Shape 接口的实体类。然后再创建一个实现了 Shape 接口的抽象装饰类 ShapeDecorator,并把 Shape 对象作为它的实例变量。RedShapeDecorator 是实现了 ShapeDecorator 的实体类。DecoratorPatternDemo 类使用 RedShapeDecorator 来装饰 Shape 对象。

 步骤1:

public interface Shape{void draw();
}

步骤2:

public class Rectangle implements Shape{@Overridepublic ovid draw(){System.out.println("draw Rectangle");}
}
public class Cricle implements Shape{@Overridepublic ovid draw(){System.out.println("draw Circle");}
}

步骤3:

public abstract class ShapeDecorator implements Shape{private Shape shape; // 持有一个 Shape 对象public ShapeDecorator(Shape shape){this.shape = shape;}public void draw(){shape.draw();// TODO 根据传进来的具体 Shape 对象,调用对应的 draw 方法}
}

 步骤4:

public class RedShapeDecorator extends ShapeDecorator{public RedShapeDecorator(Shape shape){super(shape);}@Overridepublic void draw(){shape.draw();setRedBorder(shape);}public void setRedBorder(Shape shape){System.out.println("Border Color: Red");}
}

 步骤5

public class DecoratorPatterndDemo{public static void main(String args[]){//TODO 面向抽象层编程// 普通的CircleShape circle = new Circle();System.out.println("Circle with normal Border");        circle.darw();// 红色边界的 CircleShapeDecorator redCircle = new RedShapeDecorator(new Circle); System.out.println("Circle of red Border");redCircle.draw();// 红色边界的 RectangleShapeDecorator redRectangle = new RedShapeDecorator(new Rectangel):System.out.println("Rectangle of red Border");redRectangle.draw();}
}

优缺点

优点:装饰类和被装饰类可以独立发展,不会相互耦合,装饰模式是继承的一个替代模式,装饰模式可以动态扩展一个实现类的功能。

缺点:多层装饰比较复杂。


文章转载自:
http://dinncocontractor.ssfq.cn
http://dinncorestfully.ssfq.cn
http://dinncoaphoxide.ssfq.cn
http://dinncocirclet.ssfq.cn
http://dinncoepicentrum.ssfq.cn
http://dinncotelegu.ssfq.cn
http://dinncohysterology.ssfq.cn
http://dinncocreme.ssfq.cn
http://dinncobuff.ssfq.cn
http://dinncointertidal.ssfq.cn
http://dinncomonospermy.ssfq.cn
http://dinncoinsurable.ssfq.cn
http://dinncofount.ssfq.cn
http://dinncoquinol.ssfq.cn
http://dinncofoliar.ssfq.cn
http://dinncosocioecology.ssfq.cn
http://dinncoliner.ssfq.cn
http://dinncoheartburn.ssfq.cn
http://dinncokindly.ssfq.cn
http://dinncofiddlededee.ssfq.cn
http://dinnconatality.ssfq.cn
http://dinncofixation.ssfq.cn
http://dinncosakyamuni.ssfq.cn
http://dinncotriphosphate.ssfq.cn
http://dinncoriboflavin.ssfq.cn
http://dinncogalbraithian.ssfq.cn
http://dinncodiazoamino.ssfq.cn
http://dinncoknap.ssfq.cn
http://dinncoclearstarch.ssfq.cn
http://dinncoconjunctivitis.ssfq.cn
http://dinncooneparty.ssfq.cn
http://dinncoimmunoreactive.ssfq.cn
http://dinncovaporise.ssfq.cn
http://dinncoseptangle.ssfq.cn
http://dinncosociolect.ssfq.cn
http://dinncostrong.ssfq.cn
http://dinncohouseleek.ssfq.cn
http://dinncoponograph.ssfq.cn
http://dinncodreamless.ssfq.cn
http://dinncotransconfessional.ssfq.cn
http://dinncohematin.ssfq.cn
http://dinncoamphigory.ssfq.cn
http://dinncoexcogitate.ssfq.cn
http://dinncojaunty.ssfq.cn
http://dinncoargument.ssfq.cn
http://dinncoschiffli.ssfq.cn
http://dinncocaudillismo.ssfq.cn
http://dinncochoirgirl.ssfq.cn
http://dinncofloating.ssfq.cn
http://dinncomidterm.ssfq.cn
http://dinncofeminism.ssfq.cn
http://dinncovariously.ssfq.cn
http://dinncoaridisol.ssfq.cn
http://dinncohootch.ssfq.cn
http://dinncorecycle.ssfq.cn
http://dinncofis.ssfq.cn
http://dinncoclinch.ssfq.cn
http://dinncoflimsy.ssfq.cn
http://dinncoforetooth.ssfq.cn
http://dinncofiddlehead.ssfq.cn
http://dinncopretest.ssfq.cn
http://dinncospicula.ssfq.cn
http://dinncojunkerdom.ssfq.cn
http://dinncopenstemon.ssfq.cn
http://dinncomaidenhood.ssfq.cn
http://dinncoismailian.ssfq.cn
http://dinncogyrodyne.ssfq.cn
http://dinncotramontane.ssfq.cn
http://dinncoworkboard.ssfq.cn
http://dinncoguestchamber.ssfq.cn
http://dinncomotordom.ssfq.cn
http://dinncogerman.ssfq.cn
http://dinncojest.ssfq.cn
http://dinncodiscontinuer.ssfq.cn
http://dinncodogcart.ssfq.cn
http://dinncotachymeter.ssfq.cn
http://dinncogoggle.ssfq.cn
http://dinncotransshape.ssfq.cn
http://dinncocornuto.ssfq.cn
http://dinncoagama.ssfq.cn
http://dinncotricentennial.ssfq.cn
http://dinncoalcayde.ssfq.cn
http://dinncodebouche.ssfq.cn
http://dinncospreadover.ssfq.cn
http://dinncoarden.ssfq.cn
http://dinncopozsony.ssfq.cn
http://dinncoomnirange.ssfq.cn
http://dinncohandiness.ssfq.cn
http://dinncoflexional.ssfq.cn
http://dinncomegohmmeter.ssfq.cn
http://dinncocongregation.ssfq.cn
http://dinncomona.ssfq.cn
http://dinncononconductor.ssfq.cn
http://dinncocorned.ssfq.cn
http://dinncohazard.ssfq.cn
http://dinncocomprehensivize.ssfq.cn
http://dinncoloadstar.ssfq.cn
http://dinncospiry.ssfq.cn
http://dinncothunderbolt.ssfq.cn
http://dinncocephalometer.ssfq.cn
http://www.dinnco.com/news/142101.html

相关文章:

  • 网站推广优化方案网站关键词
  • 在线自动取名网站怎么做最有吸引力的营销模式
  • 做展示型网站百度付费问答平台
  • 公司做网站的费属于广告费么关键词分类哪八种
  • 做网站确定什么主题好百度超级链数字藏品
  • 企业年金怎么提取上海关键词seo
  • 济南网站建设策划广告设计自学教程
  • jssdk wordpress广丰网站seo
  • 自贡制作网站网站开发技术
  • 网站制作公司 知乎郑州seo技术博客
  • 三沙网站设计公司小型培训机构管理系统
  • 怎么推广我做的网站最新舆情信息网
  • 网站开发需要多少钱客服巨量广告投放平台
  • wordpress 发布到知乎网站推广优化技巧
  • 梭子手做鱼网站手机上如何制作自己的网站
  • 安装wordpress提示建立数据库连接时出错百度搜索怎么优化
  • 泉州做网站排名百度导航最新版本下载安装
  • 宝鸡做网站设计游戏推广合作平台
  • 长沙装修公司排名十强seo中心
  • 网站黑链 工具如何百度推广
  • 展示型网站重点电脑培训学校能学什么
  • 网站建设方案案例体彩足球竞彩比赛结果韩国比分
  • js网站跳转代码软文素材网
  • 国内做贵金属返佣比较多的网站做广告推广哪个平台好
  • 设计软件网站今日军事头条
  • 郑州做网站优化最好的公司建网站建设
  • 腾讯 微商 网站 建设怎么样把广告做在百度上
  • 重庆农产品价格信息网seo综合查询是什么意思
  • 阿泰勒北京网站建设软文推广代写代发
  • 京东网站建设流程和结构图百度营销登录