O'Reilly logo

Python Unlocked by Arun Tigeraniya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required