Facade pattern
Key 6: Hiding system complexity for a simpler interface.
In this pattern, a main class called facade exports a simpler interface to client classes and encapsulates the complexity of interaction with many other classes of the system. It is like a gateway to a complex set of functionality, such as in the following example, the WalkingDrone class hides the complexity of synchronization of the Leg classes and provides a simpler interface to client classes:
class Leg(object):
def __init__(self,name):
self.name = name
def forward(self):
print("{0},".format(self.name), end="")
class WalkingDrone(object):
def __init__(self, name):
self.name = name
self.frontrightleg = Leg('Front Right Leg')
self.frontleftleg = Leg('Front Left Leg')
self.backrightleg = Leg('Back Right Leg')
self.backleftleg = Leg('Back Left Leg')
def walk(self):
print("\nmoving ",end="")
self.frontrightleg.forward()
...