One-Stop Shop for Complexity
In a nutshell, the facade Design Pattern provides a simple and organized way to access complex systems, making them easier to use and maintain for both developers and users.
class Subsystem1:
def operation1(self):
print("Subsystem1: Ready!")
class Subsystem2:
def operation2(self):
print("Subsystem2: Get ready!")
class Facade:
def __init__(self):
self.subsystem1 = Subsystem1()
self.subsystem2 = Subsystem2()
def do_something(self):
print("Facade initializes subsystems:")
self.subsystem1.operation1()
self.subsystem2.operation2()
print("Facade orders subsystems to perform actions:")
# ... further calls to subsystem operations
# Client code
facade = Facade()
facade.do_something() # Output:
# Facade initializes subsystems:
# Subsystem1: Ready!
# Subsystem2: Get ready!
# Facade orders subsystems to perform actions: