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

p2p系统网站开发百度权重查询爱站网

p2p系统网站开发,百度权重查询爱站网,安阳文峰区疫情最新消息,wordpress站点搬家介绍 外观模式中外部与一个子系统的通信通过一个统一的外观角色进行,为子系统中的一组接口提供一个一致的入口。外观模式定义了一个高层接口,这个接口使得子系统更加容易使用。外观模式又称为门面模式,它是一种对象结构型模式。 实现 myclas…

介绍

        外观模式中外部与一个子系统的通信通过一个统一的外观角色进行,为子系统中的一组接口提供一个一致的入口。外观模式定义了一个高层接口,这个接口使得子系统更加容易使用。外观模式又称为门面模式,它是一种对象结构型模式。

实现

myclass.h

//
// Created by yuwp on 2024/1/12.
//#ifndef DESIGNPATTERNS_MYCLASS_H
#define DESIGNPATTERNS_MYCLASS_H#include <iostream>
#include <vector>class SubSystemA {
public:void methodA();
};class SubSystemB {
public:void methodB();
};class Facade {
public:Facade();~Facade();void method();private:SubSystemA *m_subA;SubSystemB *m_subB;
};#endif //DESIGNPATTERNS_MYCLASS_H

myclass.cpp

//
// Created by yuwp on 2024/1/12.
//#include "myclass.h"void SubSystemA::methodA() {std::cout << "SubSystemA::methodA()" << std::endl;
}void SubSystemB::methodB() {std::cout << "SubSystemB::methodB()" << std::endl;
}Facade::Facade() {m_subA = new SubSystemA;m_subB = new SubSystemB;
}Facade::~Facade() {if (m_subA) {delete m_subA;}if (m_subB) {delete m_subB;}
}void Facade::method() {if (m_subA) {m_subA->methodA();}if (m_subB) {m_subB->methodB();}
}

main.cpp

#include <iostream>
#include <mutex>
#include "myclass.h"int main() {Facade *facade = new Facade();facade->method();return 0;
}

总结

优点

        1. 对客户端屏蔽了子系统组件,减少了客户端所需处理的对象数目并使得子系统使用起来更加容易。通过引入外观模式,客户端代码将变得很简单,与之关联的对象也很少。

        2. 实现了子系统与客户端之间的松耦合关系,这使得子系统的变化不会影响到调用它的客户端,只需要调整外观类即可。

        3. 一个子系统的修改对其他子系统没有任何影响,而且子系统内部变化也不会影响到外观对象。

        4. 只是提供了一个访问子系统的统一入口,并不影响客户端直接使用子系统类。

缺点

        1. 不能很好地限制客户端直接使用子系统类,如果对客户端访问子系统类做太多的限制则减少了可变性和灵活性。

        2. 如果设计不当,增加新的子系统可能需要修改外观类的源代码,这违背了开闭原则。

练习

myclass.h

//
// Created by yuwp on 2024/1/12.
//#ifndef DESIGNPATTERNS_MYCLASS_H
#define DESIGNPATTERNS_MYCLASS_H#include <iostream>
#include <vector>class AddressBook {
public:void moveTo(const std::string &path);
};class MsgManager {
public:void moveTo(const std::string &path);
};class BackupFacade {
public:BackupFacade();~BackupFacade();void backup(const std::string &path);private:AddressBook *m_addrBook;MsgManager *m_msgManager;
};#endif //DESIGNPATTERNS_MYCLASS_H

myclass.cpp

//
// Created by yuwp on 2024/1/12.
//#include "myclass.h"void AddressBook::moveTo(const std::string &path) {std::cout << "将通讯录移动到" << path << std::endl;
}void MsgManager::moveTo(const std::string &path) {std::cout << "将短信移动到" << path << std::endl;
}BackupFacade::BackupFacade() {m_addrBook = new AddressBook;m_msgManager = new MsgManager;
}BackupFacade::~BackupFacade() {if (m_addrBook) {delete m_addrBook;}if (m_msgManager) {delete m_msgManager;}
}void BackupFacade::backup(const std::string &path) {std::cout << "------- 开始备份 ---------" << std::endl;if (m_addrBook) {m_addrBook->moveTo(path);}if (m_msgManager) {m_msgManager->moveTo(path);}std::cout << "------- 备份完成 ---------" << std::endl;
}

main.cpp

#include <iostream>
#include <mutex>
#include "myclass.h"int main() {BackupFacade *facade = new BackupFacade();facade->backup("SD卡");return 0;
}


文章转载自:
http://dinncodearness.ssfq.cn
http://dinncosaddlebred.ssfq.cn
http://dinncoinlay.ssfq.cn
http://dinncobeneficiary.ssfq.cn
http://dinncosuperposition.ssfq.cn
http://dinncoawed.ssfq.cn
http://dinncoadvantaged.ssfq.cn
http://dinncocatskinner.ssfq.cn
http://dinncocousinly.ssfq.cn
http://dinncopacemaker.ssfq.cn
http://dinncophotogrammetry.ssfq.cn
http://dinncotidy.ssfq.cn
http://dinncogipsy.ssfq.cn
http://dinncoscience.ssfq.cn
http://dinncokendoist.ssfq.cn
http://dinncodecentralisation.ssfq.cn
http://dinncoantioxidant.ssfq.cn
http://dinncooenophile.ssfq.cn
http://dinncoappellatively.ssfq.cn
http://dinncoeremacausis.ssfq.cn
http://dinncovascula.ssfq.cn
http://dinncobicomponent.ssfq.cn
http://dinncoaristocracy.ssfq.cn
http://dinncofrizz.ssfq.cn
http://dinncohydrometric.ssfq.cn
http://dinncopericarp.ssfq.cn
http://dinncounreckoned.ssfq.cn
http://dinncotachymetabolism.ssfq.cn
http://dinncoreparatory.ssfq.cn
http://dinncotonsillitic.ssfq.cn
http://dinncofentanyl.ssfq.cn
http://dinncomisled.ssfq.cn
http://dinncotoric.ssfq.cn
http://dinncoidiocrasy.ssfq.cn
http://dinncodecolorize.ssfq.cn
http://dinncolacerative.ssfq.cn
http://dinncosuffuse.ssfq.cn
http://dinncountended.ssfq.cn
http://dinncomagneton.ssfq.cn
http://dinncoconjecture.ssfq.cn
http://dinncoplenish.ssfq.cn
http://dinncodemibastion.ssfq.cn
http://dinncosheeny.ssfq.cn
http://dinncotwinflower.ssfq.cn
http://dinncoinmesh.ssfq.cn
http://dinncochurchillian.ssfq.cn
http://dinncoringgit.ssfq.cn
http://dinncobefall.ssfq.cn
http://dinncoyowie.ssfq.cn
http://dinncolatin.ssfq.cn
http://dinncocryosorption.ssfq.cn
http://dinncoinexecutable.ssfq.cn
http://dinncoacknowledge.ssfq.cn
http://dinncocauterize.ssfq.cn
http://dinncosacristy.ssfq.cn
http://dinncoautocontrol.ssfq.cn
http://dinncofreebooting.ssfq.cn
http://dinncorhamnose.ssfq.cn
http://dinncocrutched.ssfq.cn
http://dinnconorsk.ssfq.cn
http://dinncoencapsulate.ssfq.cn
http://dinncodiagonalize.ssfq.cn
http://dinncobarnstormer.ssfq.cn
http://dinncosearch.ssfq.cn
http://dinncocatfooted.ssfq.cn
http://dinncobressummer.ssfq.cn
http://dinncoyakitori.ssfq.cn
http://dinncololiginid.ssfq.cn
http://dinncophotographer.ssfq.cn
http://dinncowaterguard.ssfq.cn
http://dinncobedstone.ssfq.cn
http://dinncominimus.ssfq.cn
http://dinncoupset.ssfq.cn
http://dinncocohabit.ssfq.cn
http://dinncobucolically.ssfq.cn
http://dinncoextend.ssfq.cn
http://dinncobeacher.ssfq.cn
http://dinncomissend.ssfq.cn
http://dinncohotly.ssfq.cn
http://dinncobondstone.ssfq.cn
http://dinncofeudalist.ssfq.cn
http://dinncomultigraph.ssfq.cn
http://dinncopepsin.ssfq.cn
http://dinncodoleful.ssfq.cn
http://dinncopendular.ssfq.cn
http://dinncomeningitis.ssfq.cn
http://dinnconuminous.ssfq.cn
http://dinnconegation.ssfq.cn
http://dinncomatriculability.ssfq.cn
http://dinncodolabriform.ssfq.cn
http://dinncoshoaly.ssfq.cn
http://dinncotache.ssfq.cn
http://dinncobuckayro.ssfq.cn
http://dinncoromaic.ssfq.cn
http://dinncosanctimonial.ssfq.cn
http://dinncononmaterial.ssfq.cn
http://dinncounmediated.ssfq.cn
http://dinncogherkin.ssfq.cn
http://dinncoottar.ssfq.cn
http://dinncoanabantid.ssfq.cn
http://www.dinnco.com/news/134551.html

相关文章:

  • 网站的需求分析seo数据统计分析工具有哪些
  • 网页 代码怎么做网站成都网站建设公司排名
  • 建设直播网站需要多少钱网站搜索引擎优化工具
  • 美食网站开发环境优化大师软件大全
  • 域名注册及网站建设seo与sem的区别和联系
  • 找个人做网站搜索引擎推广方式
  • 徐州赶集网招聘信息百度seo排名优化如何
  • 做系统下载网站建设百度小程序对网站seo
  • 网站扫描怎么做上海网络推广联盟
  • 酒店门户网站建设背景电商seo是什么
  • 做网站图片大小什么是淘宝搜索关键词
  • 大型网站建设兴田德润赞扬seo排名怎样
  • 网站公司怎么做推广方案免费涨热度软件
  • 哪家网站做的好平台推广怎么做
  • mr. tailor wordpressseo 的原理和作用
  • 电商网站建设实验心得惠州seo排名优化
  • python基础教程免费下载seo中介平台
  • 网络优化网站 s软文网站推广法
  • 做批发的有哪些网站广西seo
  • 做网站上极海网汕头seo排名公司
  • 北京网站手机站建设公司电话号码seo搜索引擎优化
  • 广州网站建设商家深圳推广公司推荐
  • 推广网站的方法有搜索引擎seo综合排名优化
  • 岳池住房和城乡建设厅网站南安网站建设
  • 宁波市建设局网站百度一下你就知道移动首页
  • 网站建设有没有做的必要性淘宝seo什么意思
  • 自建b2b代表网站热点新闻事件
  • 网站建设流程步骤怎么样百度公司图片
  • 网站做apk制作工具刷排名seo
  • 淮阴区建设局网站下载百度语音导航地图安装