design patterns
Facade
The Facade pattern provides a simplified interface to a complex subsystem. It does not add new functionality but instead wraps a complicated set of classes with a simpler, unified API. The key participants are the Facade (knows which subsystem classes are responsible for a request and delegates client requests to appropriate subsystem objects) and the Subsystem classes (implement subsystem functionality and handle work assigned by the Facade). Think of a hotel concierge: instead of calling the restaurant, taxi company, and theater box office yourself, you tell the concierge what you want and they coordinate everything behind the scenes. Use Facade when you want to provide a simple interface to a complex subsystem, or when you want to layer your subsystems and define entry points to each level.
Use Cases
- •Simplifying complex library or framework APIs
- •Providing a unified API for multiple microservices
- •Home automation systems (one command controls lights, AC, music)
- •Order processing systems coordinating payment, inventory, and shipping