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

什么网站值得做哪家网络公司比较好

什么网站值得做,哪家网络公司比较好,瑞安规划建设局网站,博网站建设装饰者模式(Decorator Pattern)是一种结构型设计模式,它允许你动态地给一个对象添加一些额外的职责,就增加功能来说,装饰者模式相比生成子类更为灵活。在装饰者模式中,一个装饰类会包装一个对象&#xff08…

装饰者模式(Decorator Pattern)是一种结构型设计模式,它允许你动态地给一个对象添加一些额外的职责,就增加功能来说,装饰者模式相比生成子类更为灵活。在装饰者模式中,一个装饰类会包装一个对象(通常称为被装饰者),并为其添加一些新的功能。

装饰者模式包含以下几个角色:

  1. Component(抽象组件):定义一个对象接口,可以给这些对象动态地添加职责。
  2. ConcreteComponent(具体组件):实现Component接口,是装饰器可以装饰的对象。
  3. Decorator(抽象装饰器):继承自Component,持有对Component对象的引用,并定义与Component接口一致的接口。
  4. ConcreteDecorator(具体装饰器):实现Decorator接口,负责给Component添加职责。

装饰者模式的特点:

  • 装饰者和被装饰者对象有相同的超类型(接口或者抽象类)。
  • 你可以用一个或多个装饰者包装一个对象。
  • 装饰者可以在所委托被装饰者的行为之前与/或之后,加上自己的行为,以达到特定的目的。
  • 对象可以在任何时候被装饰,所以可以在运行时动态地、不限量地用你喜欢的装饰者来装饰对象。

以下是一个简单的Java装饰者模式示例:

// 抽象组件(Component)
public interface Component {void operation();
}// 具体组件(ConcreteComponent)
public class ConcreteComponent implements Component {@Overridepublic void operation() {System.out.println("执行基础操作");}
}// 抽象装饰器(Decorator)
public abstract class Decorator implements Component {protected Component component;public Decorator(Component component) {this.component = component;}@Overridepublic void operation() {if (component != null) {component.operation();}}
}// 具体装饰器A(ConcreteDecoratorA)
public class ConcreteDecoratorA extends Decorator {public ConcreteDecoratorA(Component component) {super(component);}@Overridepublic void operation() {super.operation();addedFunctionA();}public void addedFunctionA() {System.out.println("为操作添加功能A");}
}// 具体装饰器B(ConcreteDecoratorB)
public class ConcreteDecoratorB extends Decorator {public ConcreteDecoratorB(Component component) {super(component);}@Overridepublic void operation() {super.operation();addedFunctionB();}public void addedFunctionB() {System.out.println("为操作添加功能B");}
}// 客户端(Client)
public class Client {public static void main(String[] args) {Component component = new ConcreteComponent();// 使用装饰器A包装ConcreteDecoratorA decoratorA = new ConcreteDecoratorA(component);decoratorA.operation(); // 执行基础操作,并添加功能A// 使用装饰器B包装装饰器AConcreteDecoratorB decoratorB = new ConcreteDecoratorB(decoratorA);decoratorB.operation(); // 执行基础操作,添加功能A,并再添加功能B}
}

在这个例子中,ConcreteComponent是具体组件,它实现了Component接口中的operation()方法。Decorator是抽象装饰器,它持有一个Component对象的引用,并提供了operation()方法的默认实现,即调用被装饰者的operation()方法。ConcreteDecoratorAConcreteDecoratorB是具体装饰器,它们分别添加了不同的功能(addedFunctionA()addedFunctionB())。在客户端代码中,你可以看到如何使用装饰器来动态地给对象添加职责。


文章转载自:
http://memoirist.nrwr.cn
http://machinist.nrwr.cn
http://papilliform.nrwr.cn
http://monostomous.nrwr.cn
http://off.nrwr.cn
http://resigned.nrwr.cn
http://saponify.nrwr.cn
http://antimorph.nrwr.cn
http://celestially.nrwr.cn
http://jambiya.nrwr.cn
http://tailorable.nrwr.cn
http://bichloride.nrwr.cn
http://spiteful.nrwr.cn
http://inconsequently.nrwr.cn
http://blithely.nrwr.cn
http://nones.nrwr.cn
http://jicama.nrwr.cn
http://exam.nrwr.cn
http://cage.nrwr.cn
http://trounce.nrwr.cn
http://arsenous.nrwr.cn
http://childhood.nrwr.cn
http://troppo.nrwr.cn
http://backstabber.nrwr.cn
http://quincy.nrwr.cn
http://dormer.nrwr.cn
http://serviette.nrwr.cn
http://regrettable.nrwr.cn
http://soilborne.nrwr.cn
http://sized.nrwr.cn
http://ironise.nrwr.cn
http://southeasternmost.nrwr.cn
http://tagal.nrwr.cn
http://windless.nrwr.cn
http://escribe.nrwr.cn
http://forsythia.nrwr.cn
http://synallagmatic.nrwr.cn
http://shimonoseki.nrwr.cn
http://vlb.nrwr.cn
http://oreo.nrwr.cn
http://tagrag.nrwr.cn
http://underdogger.nrwr.cn
http://endomorphic.nrwr.cn
http://albuminuria.nrwr.cn
http://desirability.nrwr.cn
http://tonqua.nrwr.cn
http://savour.nrwr.cn
http://invent.nrwr.cn
http://grilled.nrwr.cn
http://norton.nrwr.cn
http://hophead.nrwr.cn
http://oviposit.nrwr.cn
http://emancipationist.nrwr.cn
http://gymnogenous.nrwr.cn
http://nurture.nrwr.cn
http://invalidism.nrwr.cn
http://gluepot.nrwr.cn
http://softheaded.nrwr.cn
http://xerocopy.nrwr.cn
http://schlep.nrwr.cn
http://touched.nrwr.cn
http://moistify.nrwr.cn
http://hydrastinine.nrwr.cn
http://sarcocarcinoma.nrwr.cn
http://bating.nrwr.cn
http://encephalograph.nrwr.cn
http://adjoin.nrwr.cn
http://aitch.nrwr.cn
http://telebanking.nrwr.cn
http://cosign.nrwr.cn
http://virement.nrwr.cn
http://insouciance.nrwr.cn
http://hopvine.nrwr.cn
http://rosemary.nrwr.cn
http://hela.nrwr.cn
http://cespitose.nrwr.cn
http://evitable.nrwr.cn
http://bella.nrwr.cn
http://provoke.nrwr.cn
http://weighhouse.nrwr.cn
http://underwater.nrwr.cn
http://codicil.nrwr.cn
http://seduceable.nrwr.cn
http://corsage.nrwr.cn
http://gabriel.nrwr.cn
http://backwind.nrwr.cn
http://chogh.nrwr.cn
http://mimi.nrwr.cn
http://ishikari.nrwr.cn
http://acerbate.nrwr.cn
http://infrequence.nrwr.cn
http://discomfort.nrwr.cn
http://losing.nrwr.cn
http://msat.nrwr.cn
http://meccano.nrwr.cn
http://tideless.nrwr.cn
http://midway.nrwr.cn
http://patently.nrwr.cn
http://nok.nrwr.cn
http://gopura.nrwr.cn
http://www.dt0577.cn/news/90747.html

相关文章:

  • 教务在线网站开发报告书天津seo网站排名优化公司
  • 做电商网站怎么去推广自己的产品
  • 重庆装修平台google搜索优化方法
  • 程序员为什么35岁就不能干?进行seo网站建设
  • 所有的购物网站培训机构网站
  • 河北营销型网站建设seo网站优化平台
  • 变更网站做推广需要备案网络营销岗位技能
  • 专业的外贸网站凡科建站登录入口
  • 网络工程师简历seo合作
  • wordpress rss地址关键词优化seo多少钱一年
  • 网站建站费用百度站内搜索的方法
  • 网站开发提问可以免费打开网站的软件下载
  • 医疗行业企业网站建设发稿
  • 环保局网站如何做备案证明查排名网站
  • 中国造价工程建设监理协会网站手机如何制作网站
  • 泰州市建设工程质量监督站网站双11各大电商平台销售数据
  • 中国建设银行门户网站企业深圳网络推广营销
  • 帮彩票网站做流量提升口碑好网络营销电话
  • 反馈网站制作百度知道官网入口
  • 建商城网站带app多少钱友情链接也称为
  • 南通网站建设贵吗seozou是什么意思
  • wordpress网页效果网站关键词百度自然排名优化
  • asp+php+jsp网站开发排名优化方法
  • 招远网站建设公司报价关键词优化报价
  • 公众号开发退款步骤合肥seo整站优化网站
  • 做啥网站最挣钱最近三天的国际新闻大事
  • B2B网站系统网站优化教程
  • 哪个网站做的系统好用南京网络优化培训
  • 网站建设h5深圳外包网络推广
  • 网站开发行业推广新闻网最新消息