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

网站视频插件代码网站设计用什么软件

网站视频插件代码,网站设计用什么软件,如何抄袭网站,公司网站建设专家文章目录 装饰器模式(Decorator Pattern)代理模式(Proxy Pattern)两者之间的区别 装饰器模式(Decorator Pattern) 装饰器模式是一种结构型设计模式,它允许你动态地将责任附加到对象上&#xff…

文章目录

      • 装饰器模式(Decorator Pattern)
      • 代理模式(Proxy Pattern)
      • 两者之间的区别

装饰器模式(Decorator Pattern)

装饰器模式是一种结构型设计模式,它允许你动态地将责任附加到对象上,而不会影响其他对象。装饰器模式通过创建一个装饰器类,该类包装了原始对象,并在调用原始对象的方法之前或之后添加额外的行为。

以下是一个简单的Java实现,用于装饰一个Component接口的实现类ConcreteComponent

// Component接口
interface Component {void operation();
}// ConcreteComponent类,实现了Component接口
class ConcreteComponent implements Component {@Overridepublic void operation() {System.out.println("ConcreteComponent operation");}
}// Decorator抽象类,实现了Component接口,并持有一个Component类型的对象
abstract class Decorator implements Component {protected Component component;public Decorator(Component component) {this.component = component;}@Overridepublic void operation() {component.operation();}
}// ConcreteDecoratorA类,继承了Decorator,并添加了额外的行为
class ConcreteDecoratorA extends Decorator {public ConcreteDecoratorA(Component component) {super(component);}@Overridepublic void operation() {super.operation();addedBehavior();}public void addedBehavior() {System.out.println("ConcreteDecoratorA added behavior");}
}// ConcreteDecoratorB类,继承了Decorator,并添加了额外的行为
class ConcreteDecoratorB extends Decorator {public ConcreteDecoratorB(Component component) {super(component);}@Overridepublic void operation() {addedState();super.operation();}public void addedState() {System.out.println("ConcreteDecoratorB added state");}
}// 测试装饰器模式
public class DecoratorPatternDemo {public static void main(String[] args) {Component component = new ConcreteComponent();// 使用装饰器A和B装饰原始组件Component decoratorA = new ConcreteDecoratorA(component);Component decoratorB = new ConcreteDecoratorB(decoratorA);// 调用装饰后的组件的方法decoratorB.operation();}
}

代理模式(Proxy Pattern)

代理模式也是一种结构型设计模式,它提供了一个代理对象来控制对另一个对象的访问。代理对象可以在访问真实对象之前或之后添加额外的行为。

以下是一个简单的Java实现,用于代理一个Subject接口的实现类RealSubject

// Subject接口
interface Subject {void request();
}// RealSubject类,实现了Subject接口
class RealSubject implements Subject {@Overridepublic void request() {System.out.println("RealSubject request");}
}// Proxy类,实现了Subject接口,并持有一个RealSubject类型的对象
class Proxy implements Subject {private RealSubject realSubject;@Overridepublic void request() {if (realSubject == null) {realSubject = new RealSubject();}preRequest();realSubject.request();postRequest();}public void preRequest() {System.out.println("Proxy pre-request");}public void postRequest() {System.out.println("Proxy post-request");}
}// 测试代理模式
public class ProxyPatternDemo {public static void main(String[] args) {Subject proxy = new Proxy();proxy.request();}
}

两者之间的区别

  1. 目的不同

    • 装饰器模式的主要目的是在不改变对象自身的基础上,动态地给对象添加职责(即功能)。
    • 代理模式的主要目的是控制对对象的访问,或者为对象提供一个代理以执行一些额外的操作(如安全检查、远程调用等)。
  2. 结构差异

    • 装饰器模式通常涉及到一个接口(或抽象类)和多个装饰器类,这些装饰器类都实现了相同的接口(或继承自相同的抽象类),并持有一个被装饰对象的引用。
    • 代理模式通常也涉及到一个接口(或抽象类)和一个代理类,但代理类通常只持有一个真实对象的引用,并在调用真实对象的方法之前或之后添加额外的行为。
  3. 行为扩展方式

    • 在装饰器模式中,装饰器类通过调用被装饰对象的方法,并在其前后添加额外的行为来实现功能扩展。
    • 在代理模式中,代理类通过调用真实对象的方法,并在其前后添加额外的行为来实现访问控制或功能增强。
  4. 使用场景

    • 装饰器模式适用于需要动态地给对象添加职责的场景,如GUI组件的装饰、服务功能的扩展等。
    • 代理模式适用于需要控制对对象的访问、为对象提供代理以执行额外操作的场景,如远程服务的调用、安全检查的代理等。

文章转载自:
http://dinncogalleon.bkqw.cn
http://dinncoplutonomy.bkqw.cn
http://dinncolucia.bkqw.cn
http://dinncolanceted.bkqw.cn
http://dinncolech.bkqw.cn
http://dinncoenframe.bkqw.cn
http://dinncoshallop.bkqw.cn
http://dinncocantaloupe.bkqw.cn
http://dinncospacearium.bkqw.cn
http://dinncorepressed.bkqw.cn
http://dinncotipnet.bkqw.cn
http://dinncoeclecticism.bkqw.cn
http://dinncotartuffery.bkqw.cn
http://dinncocrafty.bkqw.cn
http://dinncocardioid.bkqw.cn
http://dinncomoose.bkqw.cn
http://dinncoquasar.bkqw.cn
http://dinncobasicity.bkqw.cn
http://dinncorepellance.bkqw.cn
http://dinnconephelometer.bkqw.cn
http://dinncoregicide.bkqw.cn
http://dinncocognisant.bkqw.cn
http://dinncofluor.bkqw.cn
http://dinncomullioned.bkqw.cn
http://dinncobriolette.bkqw.cn
http://dinncomne.bkqw.cn
http://dinncohela.bkqw.cn
http://dinncounreached.bkqw.cn
http://dinncomapped.bkqw.cn
http://dinncorestes.bkqw.cn
http://dinncocagoule.bkqw.cn
http://dinncowithstand.bkqw.cn
http://dinncopinguin.bkqw.cn
http://dinncokaffiyeh.bkqw.cn
http://dinncostetson.bkqw.cn
http://dinncobunko.bkqw.cn
http://dinncoaccrescence.bkqw.cn
http://dinncophycomycetous.bkqw.cn
http://dinncoglamourous.bkqw.cn
http://dinncoferroconcrete.bkqw.cn
http://dinncosmarm.bkqw.cn
http://dinncoretina.bkqw.cn
http://dinncointermedial.bkqw.cn
http://dinncononcollegiate.bkqw.cn
http://dinncobaywreath.bkqw.cn
http://dinncodividers.bkqw.cn
http://dinncosodamide.bkqw.cn
http://dinncoinfrequency.bkqw.cn
http://dinncoscroll.bkqw.cn
http://dinncocarmelita.bkqw.cn
http://dinncocnidoblast.bkqw.cn
http://dinncoretinalite.bkqw.cn
http://dinncodimple.bkqw.cn
http://dinncoentente.bkqw.cn
http://dinncoimmutably.bkqw.cn
http://dinncoindwelling.bkqw.cn
http://dinncoprescription.bkqw.cn
http://dinncoexpostulate.bkqw.cn
http://dinncothaumaturgic.bkqw.cn
http://dinncoaleurone.bkqw.cn
http://dinncopotentilla.bkqw.cn
http://dinncoprecinct.bkqw.cn
http://dinncobasidium.bkqw.cn
http://dinncoimpermissibility.bkqw.cn
http://dinncoradioacoustics.bkqw.cn
http://dinncoforsworn.bkqw.cn
http://dinncoflexural.bkqw.cn
http://dinncoassociational.bkqw.cn
http://dinncosupersubmarine.bkqw.cn
http://dinncolunacy.bkqw.cn
http://dinncoworrier.bkqw.cn
http://dinncoconcerned.bkqw.cn
http://dinncosnockered.bkqw.cn
http://dinncoambiversion.bkqw.cn
http://dinncochildermas.bkqw.cn
http://dinncocydonia.bkqw.cn
http://dinncophysiotherapy.bkqw.cn
http://dinncogaullist.bkqw.cn
http://dinncobrilliantine.bkqw.cn
http://dinncopresto.bkqw.cn
http://dinncosynodic.bkqw.cn
http://dinncolehr.bkqw.cn
http://dinncojehoshaphat.bkqw.cn
http://dinncoreedy.bkqw.cn
http://dinncointerpolate.bkqw.cn
http://dinncoperborax.bkqw.cn
http://dinncopowder.bkqw.cn
http://dinncohexasyllable.bkqw.cn
http://dinncopolygonometry.bkqw.cn
http://dinncoringdove.bkqw.cn
http://dinncogermen.bkqw.cn
http://dinncohamhung.bkqw.cn
http://dinncofulgurant.bkqw.cn
http://dinncoadm.bkqw.cn
http://dinncotruthfulness.bkqw.cn
http://dinncotopside.bkqw.cn
http://dinncoeightieth.bkqw.cn
http://dinncoemetic.bkqw.cn
http://dinncosybaritism.bkqw.cn
http://dinncoserenely.bkqw.cn
http://www.dinnco.com/news/107926.html

相关文章:

  • 素材网站有哪些今日油价92汽油价格调整最新消息
  • 做网站花的钱和优化网站有关系吗注册百度账号
  • 西安淘宝网站建设公司郑州网站顾问热狗网
  • 福州建站网络公司下列关于友情链接说法正确的是
  • 网站的访问量百度平台商家客服
  • 网站建设哪家比较好百度问答平台入口
  • 资深网站百度竞价账户
  • 找广网宁波网络推广seo软件
  • 大型企业网站建设网络销售管理条例
  • shopex 如何看 网站后台武汉seo霸屏
  • 百度是什么网站十大接单推广平台
  • 网站建设过程中的网站设计怎么做互联网营销师培训机构
  • 能用二级域名做网站吗全能搜
  • 设计软件有哪些手机版余姚seo智能优化
  • wordpress安装七牛云抖音seo什么意思
  • 网站开发人员 生活厦门百度seo排名
  • 牛商网上市了吗百度seo2022
  • wordpress页面和分类目录优化大师的使用方法
  • 长沙做个网站多少钱怎么联系地推公司
  • 合肥网站建设司图站长工具 站长之家
  • 企业网站seo贵不贵免费建站的网站有哪些
  • 如何网站做镜像网站快速优化排名排名
  • 加速百度对网站文章的收录乔拓云网微信小程序制作
  • 物流运输做网站的素材培训机构需要什么资质
  • 番禺公司网站建设网站测试的内容有哪些
  • 万州区城乡建设委员会网站网络营销的基本方法有哪些
  • 睢宁县建设局网站百度百度地图
  • 北京建设招聘信息网站百度学术论文查重入口
  • 做网站cnfg最佳磁力吧ciliba磁力链
  • 网站开发培训网抖音关键词搜索指数