python设计模式---结构型之门面模式
门面,系统,客户端~
from django.test import TestCase class Hotelier: def __init__(self): print('Arranging the Hotel for Marriage? ---') def _is_available(self): print('Is the Hotel free for the event on given dat?') return True def book_hotel(self): if self._is_available(): print('Registered the Booking\n') class Florist: def __init__(self): print('Flower Decorations for the Events? ---') def set_flower_requirements(self): print('Carnations, Roses and Lilies would be used for Decorations\n') class Caterer: def __init__(self): print('Food Arrangements for the Event ---') def set_cuisine(self): print('Chinese & Continental Cuisine to be served\n') class Musician: def __init__(self): print('Musical Arrangements for the Marriage ---') def set_music_type(self): print('Jazz and Classical will be played\n') class EventManager: def __init__(self): print('Event Manager: Let me talk to the folks\n') def arrange(self): self.hotelier = Hotelier() self.hotelier.book_hotel() self.florist = Florist() self.florist.set_flower_requirements() self.caterer = Caterer() self.caterer.set_cuisine() self.musician = Musician() self.musician.set_music_type() class You: def __init__(self): print('Your:: Whoa! Marriage Arrangements???!!!') def ask_event_manager(self): print('You:: Let us Contack the Event Manager\n') em = EventManager() em.arrange() def __del__(self): print('Your:: Thanks to Event Manager, all preparations done! Phew!') you = You() you.ask_event_manager()
Your:: Whoa! Marriage Arrangements???!!! You:: Let us Contack the Event Manager Event Manager: Let me talk to the folks Arranging the Hotel for Marriage? --- Is the Hotel free for the event on given dat? Registered the Booking Flower Decorations for the Events? --- Carnations, Roses and Lilies would be used for Decorations Food Arrangements for the Event --- Chinese & Continental Cuisine to be served Musical Arrangements for the Marriage --- Jazz and Classical will be played Your:: Thanks to Event Manager, all preparations done! Phew!
python设计模式---结构型之门面模式的更多相关文章
- python设计模式---结构型之代理模式
主要想着nginx:) from abc import ABCMeta, abstractmethod # 结构型设计模式---代理模式 class Actor: def __init__(self) ...
- JAVA设计模式 5【结构型】代理模式的理解与使用
今天要开始我们结构型 设计模式的学习,设计模式源于生活,还是希望能通过生活中的一些小栗子去理解学习它,而不是为了学习而学习这些东西. 结构型设计模式 结构型设计模式又分为 类 结构型 对象 结构型 前 ...
- 【结构型】Flyweight模式
享元模式的主要目的.意图是为对象的大量使用提供一种共享机制.该模式的思想重在复用.共享复用.像文字.列表中的格子等这类多数都是需要考虑复用技术,否则必将大量耗费内存空间而使资源以及性能等大量耗费.该模 ...
- python设计模式之模型-视图-控制器模式
python设计模式之模型-视图-控制器模式 关注点分离( Separation of Concerns, SoC)原则是软件工程相关的设计原则之一. SoC原则背后的思想是将一个应用切分成不同的部分 ...
- 设计模式-结构型模式,python组合模式
设计模式上大的方向上分继承和组合,就是类模式和对象模式.此篇的组合模式非继承和组合概念中的组合.桥接 策略 代理 装饰者都用了组合,此组合非彼组合. 组合模式 组合模式(Composite Patte ...
- 设计模式-结构型模式,python桥接模式
桥接模式 桥接(Bridge)是用于把抽象化与实现化解耦,使得二者可以独立变化.这种类型的设计模式属于结构型模式,它通过提供抽象化和实现化之间的桥接结构,来实现二者的解耦. 这种模式涉及到一个作为桥接 ...
- 设计模式 结构型模式 外观模式(Facade Pattern)
在软件开发过程中,客户端程序经常会与复杂系统的内部子系统进行耦合,从而导致客户端程序随着子系统的变化而变化. 这时为了将复杂系统的内部子系统与客户端之间的依赖解耦,从而就有了外观模式,也称作 ”门面“ ...
- Java设计模式——结构型模式
Java设计模式中共有7种结构型模式:适配器模式.装饰模式.代理模式.外观模式.桥接模式.组合模式.享元模式.其中对象的适配器模式是各种模式的起源,其关系如下面的图:1.适配器模式 适配器模式将某个类 ...
- 【设计模式】结构型03外观模式(Facade Pattern)
[设计模式]结构型02装饰模式(Decorator Pattern) 意图:为子系统中的一组接口提供一个一致的界面,外观模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 主要解决:降低访问 ...
随机推荐
- ABP中的拦截器之ValidationInterceptor(下)
在上篇我分析了整个ABP中ValitationInterceptor的整个过程,就其中涉及到的Validator过程没有详细的论述,这篇文章就这个过程进行详细的论述,另外任何一个重要的特性如何应用是最 ...
- EntityFramework Core笔记:查询数据(3)
1. 基本查询 1.1 加载全部数据 using System.Linq; using (var context = new LibingContext()) { var roles = contex ...
- Java使用J4L识别验证码
1.首先要下载j4l的相应文件和jar 下载地址:http://www.java4less.com/ocrtools/ocrtools.php?info=download 2.下载完成之后解压,文件目 ...
- unix文件系统中的硬链接和软连接
硬链接: 一般情况下,文件名和inode号码是"一一对应"关系,每个inode号码对应一个文件名.但是,Unix/Linux系统允许,多个文件名指向同一个inode号码. 这意味着 ...
- Mariadb修改root密码
默认情况下,新安装的 mariadb 的密码为空,在shell终端直接输入 mysql 就能登陆数据库. 如果是刚安装第一次使用,请使用 mysql_secure_installation 命令初始化 ...
- springboot 拦截器
拦截器的实现: 创建自定义拦截器CustomInterceptor: package com.xc.boot.handler; import org.springframework.stereotyp ...
- Dubbo2.6.5+Nacos注册中心(代替Zookeeper)
在上一节的小栗子的基础上,只需要更改两个地方 第一个:父工程的pom依赖增加 <!-- Dubbo Nacos registry dependency --> <dependency ...
- BIOS翻译
BIOS翻译 BIOS(Basic Input/Output System—基本输入输出系统).BIOS可以视为是一个永久地记录在ROM中的一个软件 Main主要信息 :main 主要信息 advan ...
- java实现文件的断点续传
java实现文件的断点续传: 依赖: <!--文件上传--> <dependency> <groupId>commons-fileupload</groupI ...
- Spring MVC 使用问题与解决--HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
1.HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 解决 使用jre1.7 Spring4.3 2.spr ...