python设计模式(外观模式)
来源:互联网 发布:非洲的基础网络情况 编辑:程序博客网 时间:2024/05/22 13:13
学习版本3.5.2
外观模式(Facade Pattern)向客户端提供一个可以访问系统的接口,隐藏了系统的复杂性。
比如说,生产a产品需要abc三个流水线生产的零件,我只想管a产品的生产。
class ProductionLineA(object): def create(self): print("create component a")class ProductionLineB(object): def create(self): print("create component b")class ProductionLineC(object): def create(self): print("create component c")class AssembleProductA(object): def assemble(self): print("use component a,b and c to assemble product a")class YieldProduct(object): def __init__(self): self.pla = ProductionLineA() self.plb = ProductionLineB() self.plc = ProductionLineC() self.apa = AssembleProductA() def product(self): self.pla.create() self.plb.create() self.plc.create() self.apa.assemble()if __name__ == "__main__": yp = YieldProduct() yp.product()
运行结果
create component acreate component bcreate component cuse component a,b and c to assemble product a
阅读全文
0 0
- Python设计模式-外观模式
- python设计模式(外观模式)
- Python设计模式(九)【外观模式】
- python设计模式之外观模式
- 设计模式--外观模式
- 设计模式-外观模式
- 设计模式:外观模式
- 设计模式----外观模式
- 设计模式------外观模式
- 设计模式 外观模式
- 设计模式-【外观模式】
- 设计模式-----外观模式
- 设计模式 - 外观模式
- 设计模式 - 外观模式
- 设计模式- 外观模式
- 设计模式-外观模式
- 设计模式 - 外观模式
- 设计模式-外观模式
- [模板][洛谷P1835]素数密度(区间筛)
- AndroidStudio 离线情况下使用GreenDao数据库框架的方式
- R语言学習
- 【noip 2016】组合数问题
- bootstrap table关于排序列添加图标的方法--查漏补缺
- python设计模式(外观模式)
- linux中文件的分区
- Beginning Django.pdf 英文原版 免费下载
- c++实现链表归并排序
- Navigator is deprecated and has been removed from this package
- Android监听软键盘打开收起事件(软键盘自带收起按钮)
- java作业
- checkbox 选中事件
- PagerAdapter和FragmentPagerAdapter和FragmentStatePagerAdapter区别