Basic Description: The appearance mode does not change the structure of the original system. By creating the appearance class, the complex work of external interaction is provided.
Today, my boss has two jobs: 1. Arrange for a scan. 2. The security team is ready to receive the tour Delegation
The company's original organization has three departments A, B, and C.
In order to complete the tasks assigned by the boss, I had to act as the appearance class, arrange for A and C departments to scan the snow (the snow is very big and requires two departments), and arrange for B Department to receive the visit (B Department sister, sister can create an atmosphere)
[Python]
#-*-Coding: UTF-8 -*-
######################################## ###############
#
# Facade. py
# Python implementation of the Class client
# Generated by Enterprise effecect
# Created on: 12-December-2012 10:52:19
# Original author: zjm
#
######################################## ###############
From _ future _ import division
From _ future _ import print_function
From _ future _ import unicode_literals
From future_builtins import *
Class Department (object ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "None "):
Self. name = name
Pass
Def Operation (self ):
Print (self. name + "" + "does this work ")
Pass
Class internal menta (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentA "):
Super (DepartmentA, self). _ init _ (name)
Pass
Class DepartmentB (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentB "):
Super (DepartmentB, self). _ init _ (name)
Pass
Class DepartmentC (Department ):
"This class (a) implements subsystem functionality, (B) handles work assigned
The Facade object, and (c) keeps no reference to the facade.
"""
Def _ init _ (self, name = "DepartmentC "):
Super (DepartmentC, self). _ init _ (name)
Pass
Class Facade (object ):
"This class (a) knows which subsystem classes are responsible for a request, and
(B) delegates client requests to appropriate subsystem objects.
"""
M_DepartmentA = DepartmentA ()
M_DepartmentB = DepartmentB ()
M_DepartmentC = DepartmentC ()
Def _ init _ (self ):
Self. m_inclumenta = inclumenta ()
Self. m_DepartmentB = DepartmentB ()
Self. m_DepartmentC = DepartmentC ()
Def CleanSnow (self ):
Print ("CleanSnow :")
Self. m_DepartmentA.Operation ()
Self. m_DepartmentC.Operation ()
Pass
Def ReceiveVisit (self ):
Print ("ReceiveVisit :")
Self. m_DepartmentB.Operation ()
Pass
# Client (boss)
If (_ name __= = "_ main __"):
Class client:
M_Facade = Facade ()
M_Facade.CleanSnow ()
M_Facade.ReceiveVisit ()