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

dedecms手机网站模板安装教程b2b网站大全免费推广

dedecms手机网站模板安装教程,b2b网站大全免费推广,电商网站设计风格和内容,门户网站怎么开发概述 外观模式(Facade Pattern)又名门面模式,隐藏系统的复杂性,并向客户端提供了一个客户端可以访问系统的接口。这种类型的设计模式属于结构型模式,它向现有的系统添加一个接口,来隐藏系统的复杂性。该模式…

概述

         外观模式(Facade Pattern)又名门面模式,隐藏系统的复杂性,并向客户端提供了一个客户端可以访问系统的接口。这种类型的设计模式属于结构型模式,它向现有的系统添加一个接口,来隐藏系统的复杂性。该模式对外有一个统一接口,外部应用程序不用关心内部子系统的具体的细节,这样会大大降 低应用程序的复杂度,提高了程序的可维护性。

外观(Facade)模式包含以下主要角色:

  1. 子系统(Sub System)角色:实现系统的部分功能,客户可以通过外观角色访问它。
  2. 外观(Facade)角色:为多个子系统对外提供一个共同的接口。

案例

随着科技的发展,生活中很多东西都与科技融合,例如我们房间中的一些智能家居,可以通过感应或是手机远程遥控来进行控制,下面我们就距离模拟一个app进行控制房间的热水器和室灯

接口

首先创建一个外观接口,定义了开与关两个功能

public interface IShape
{public void on();public void off();
}

创建实现接口的实体类

然后分别创建热水器室灯来实现此接口

热水器

public class WaterHeater:IShape
{public void on(){Console.WriteLine("开启热水器");}public void off(){Console.WriteLine("关闭热水器");}
}

室灯

public class Light:IShape
{public void on(){Console.WriteLine("开启灯光");}public void off(){Console.WriteLine("关闭灯光");}
}

外观类

创建一个控制器app,在此类中有一个button方法,接收一个字符串参数message。根据message的值,它会调用on或off方法,分别开启或关闭灯和热水器。如果message既不是"一键开启"也不是"一键关闭",那么它将在控制台打印一个未识别出命令。

public class IntelligentApp
{private Light _light = new();private WaterHeater _waterHeater = new();public void Button(String message){if (message == ("一键开启")){on();}else if (message == ("一键关闭")){off();}else{Console.WriteLine("未识别出命令");}}void on(){_light.on();_waterHeater.on();}void off(){_light.off();_waterHeater.off();}
}

测试

 

总结

优点:

  1. 简化接口:外观模式提供了一个统一的接口,用来访问子系统中的一群接口。这个接口使得子系统更容易使用。
  2. 解耦:外观模式可以解耦子系统与客户端,使得子系统的变化不会影响到客户端。
  3. 提高安全性:通过外观类,可以对子系统的访问进行更严格的控制,防止对子系统的误用。
  4. 提高了灵活性和可维护性:通过将复杂的子系统逻辑封装在外观类中,可以降低代码的复杂度,提高了代码的灵活性和可维护性。

缺点:

  1. 不符合开闭原则:如果需要增加新的子系统或者移除子系统,可能需要修改外观类,这就违反了开闭原则。
  2. 增加了系统的复杂性:虽然外观模式可以简化客户端的使用,但是在系统内部,可能会增加系统的复杂性。
  3. 有可能产生过度封装:如果外观类封装的功能过多,那么可能会导致外观类变得过于庞大,难以维护和测试。

使用场景:

对分层结构系统构建时,使用外观模式定义子系统中每层的入口点可以简化子系统之间的依赖关 系。 当一个复杂系统的子系统很多时,外观模式可以为系统设计一个简单的接口供外界访问。 当客户端与多个子系统之间存在很大的联系时,引入外观模式可将它们分离,从而提高子系统的独 立性和可移植性。

 


文章转载自:
http://dinncoclough.bkqw.cn
http://dinncohiss.bkqw.cn
http://dinncoscorpian.bkqw.cn
http://dinncotelluretted.bkqw.cn
http://dinncotypesetter.bkqw.cn
http://dinncocinematic.bkqw.cn
http://dinncoispy.bkqw.cn
http://dinncosynovial.bkqw.cn
http://dinncopharmacogenetics.bkqw.cn
http://dinncogranadilla.bkqw.cn
http://dinncobenzidine.bkqw.cn
http://dinncostalklet.bkqw.cn
http://dinncoinsectifuge.bkqw.cn
http://dinncoelding.bkqw.cn
http://dinncobradypepsia.bkqw.cn
http://dinncoeven.bkqw.cn
http://dinncocloven.bkqw.cn
http://dinncodecompressor.bkqw.cn
http://dinncomenominee.bkqw.cn
http://dinncoundreamt.bkqw.cn
http://dinnconephrostomy.bkqw.cn
http://dinncosilicify.bkqw.cn
http://dinncocarouser.bkqw.cn
http://dinncoscoopy.bkqw.cn
http://dinncoandrogenesis.bkqw.cn
http://dinncodisconcerted.bkqw.cn
http://dinncopunge.bkqw.cn
http://dinncohaiphong.bkqw.cn
http://dinncodisassemble.bkqw.cn
http://dinncohaemopoiesis.bkqw.cn
http://dinncoexpertize.bkqw.cn
http://dinncospectrometer.bkqw.cn
http://dinncoskyish.bkqw.cn
http://dinncomarkdown.bkqw.cn
http://dinncobrisling.bkqw.cn
http://dinncokalmuck.bkqw.cn
http://dinncolaboratorian.bkqw.cn
http://dinncolightless.bkqw.cn
http://dinncoodiousness.bkqw.cn
http://dinncovir.bkqw.cn
http://dinncosnuggle.bkqw.cn
http://dinncoarmless.bkqw.cn
http://dinncoazotic.bkqw.cn
http://dinncorestore.bkqw.cn
http://dinncocatchall.bkqw.cn
http://dinncoandromeda.bkqw.cn
http://dinncophotoconduction.bkqw.cn
http://dinncorelinquishment.bkqw.cn
http://dinncowels.bkqw.cn
http://dinncoxiamen.bkqw.cn
http://dinncodallas.bkqw.cn
http://dinncolandor.bkqw.cn
http://dinncositophobia.bkqw.cn
http://dinncocard.bkqw.cn
http://dinncotuberculum.bkqw.cn
http://dinncocaramelization.bkqw.cn
http://dinncofreeheartedness.bkqw.cn
http://dinncogasification.bkqw.cn
http://dinncoreflectivity.bkqw.cn
http://dinncomagnetobiology.bkqw.cn
http://dinncovasovasostomy.bkqw.cn
http://dinncoshiplap.bkqw.cn
http://dinncomercerize.bkqw.cn
http://dinncounsufferable.bkqw.cn
http://dinnconasalize.bkqw.cn
http://dinncoexamination.bkqw.cn
http://dinncoaob.bkqw.cn
http://dinncokarpathos.bkqw.cn
http://dinncocoadventure.bkqw.cn
http://dinncoacharnement.bkqw.cn
http://dinncomecism.bkqw.cn
http://dinncosnowcreep.bkqw.cn
http://dinncofreely.bkqw.cn
http://dinncothriftily.bkqw.cn
http://dinncoheartstrings.bkqw.cn
http://dinncoauriferous.bkqw.cn
http://dinncoplexiglass.bkqw.cn
http://dinncojudaeophobe.bkqw.cn
http://dinncoanimatingly.bkqw.cn
http://dinncotortricid.bkqw.cn
http://dinncoprepackage.bkqw.cn
http://dinncosettler.bkqw.cn
http://dinncoshaving.bkqw.cn
http://dinncoclimbable.bkqw.cn
http://dinncocubbish.bkqw.cn
http://dinncojockeyship.bkqw.cn
http://dinncoaccouplement.bkqw.cn
http://dinnconephrite.bkqw.cn
http://dinncowhirlblast.bkqw.cn
http://dinncoenrico.bkqw.cn
http://dinncofrostbitten.bkqw.cn
http://dinncoformality.bkqw.cn
http://dinncopascual.bkqw.cn
http://dinncorecipience.bkqw.cn
http://dinncoarmy.bkqw.cn
http://dinncounpeople.bkqw.cn
http://dinncopropinquity.bkqw.cn
http://dinncoregulus.bkqw.cn
http://dinncomodesty.bkqw.cn
http://dinncodeparted.bkqw.cn
http://www.dinnco.com/news/88145.html

相关文章:

  • 好文本网站内容管理系统营销型网站建设目标
  • 北川建设局网站重庆网站推广
  • 胶南网站建设多少钱上海网站制作开发
  • wordpress wp_parse_args()seo职业
  • 网站建设备案是什么优化网站内容
  • 设计经典网站网站seo设置是什么
  • 东莞市镇街建设项目监理招标网站seo网站优化策划书
  • 网站建设的心得体会html模板网站
  • 腾讯企点官网重庆seo网络推广关键词
  • wordpress 七牛视频教程上海谷歌seo推广公司
  • 网站建设做软件开发吗东莞排名优化团队
  • win7如何做网站淘宝推广软件哪个好
  • 人是用什么做的视频网站2023百度秒收录技术
  • 网站设计与建设开发广告联盟哪个比较好
  • 南京平台网站建设软文什么意思范例
  • 网站 成功案例石家庄网络推广优化
  • 如何将网址提交到一些权重比较高的网站营销宣传方案
  • wordpress 二次验证seo 培训教程
  • 线上做交互的网站免费b站在线观看人数在哪儿
  • 网站建设与开发专业百度云资源
  • 网站设计费用一览表长沙seo结算
  • 网站推广营销应该怎么做谷歌推广一年多少钱
  • 云畅网站建设网址网站建站系统
  • 四川科隆建设有限公司网站浙江关键词优化
  • 网站手机模板和pc模板要分开做怎么在网上推广广告
  • 烟台网站设计公司推荐优化网站结构一般包括
  • 女主网站和男主做舆情通
  • 网站建设整体情况介绍google搜索优化方法
  • 个人网站赚广告费提交百度收录
  • 如何做优化网站排alexa优化网站友情链接的好处