Appearance (facade) Mode: Provides a consistent interface for a group of interfaces in the subsystem.
-- This mode defines a high-level interface, which makes this subsystem easier to use.
Differences from other models: Similar to the combined version of "simple factory mode + policy mode", the appearance class interface is not a simple call of the corresponding interface of the function class, but encapsulated into a new interface.
Use Cases: To maintain a legacy large system, it may be very difficult to maintain and expand, but it contains very important functions. New Development must depend on it, in this way, the appearance facade class is added, and a clear and simple interface is encapsulated for the system to allow the new system to interact with the facade object, and the facade to interact with the legacy code in all the complicated work.
# Encoding = UTF-8 ## by Panda # facade def printinfo (Info): Print Unicode (Info, 'utf-8 '). encode ('gbk') Class stock1 (): name = 'stock 1' def buy (Self): printinfo ('buy '+ self. name) def evaluate (Self): printinfo ('sell' + self. name) Class stock2 (): name = 'stock 2' def buy (Self): printinfo ('buy '+ self. name) def evaluate (Self): printinfo ('sell' + self. name) Class nationdebt1 (): name = 'national debt 1' def buy (Self): printinfo ('shop' + self. name) def evaluate (Self): printinfo ('sell' + self. name) Class realty1 (): name = 'realestate 1' def buy (Self): printinfo ('buy '+ self. name) def evaluate (Self): printinfo ('sell' + self. name) # fund class fund (): gu1 = none gu2 = none nd1 = none rt1 = none def _ init _ (Self): Self. gu1 = stock1 () self. gu2 = stock2 () self. nd1 = nationdebt1 () self. rt1 = realty1 () def buyfund (Self): Self. gu1.buy () self. gu2.buy () self. nd1.buy () self. rt1.buy () def sellfund (Self): Self. gu1.20.() self. gu2.133 () self. nd1.merge () self. rt1.parse () def clientui (): myfund = Fund () myfund. buyfund () myfund. sellfund () returnif _ name _ = '_ main _': clientui ();
Class Diagram: