Appearance mode (Facade), Provides a consistent interface for a set of interfaces in a subsystem . The facade pattern defines a high-level interface , This interface makes this subsystem easier to use .
The difference between appearance mode and adapter mode is : Appearance mode is to design a unified interface for small systems under large systems , The adapter mode is designed for various interface calls of different systems .
advantage :
class API1:
def Save(self):
print(' Save the data A')
def Del(self):
print(' Delete data A')
class API2:
def Save(self):
print(' Save the data B')
def Del(self):
print(' Delete data B')
class Facade:
def __init__(self):
self._api1 = API1()
self._api2 = API2()
def SaveAll(self):
[obj.Save() for obj in [self._api1, self._api2]]
def DelAll(self):
[obj.Save() for obj in [self._api1, self._api2]]
if __name__ == '__main__':
test = Facade()
test.SaveAll()
test.DelAll()