Html/Javascript widget

Saturday, 10 September 2022

the Facade design pattern

The facade pattern (or façade) is a structural pattern Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy analogous to a facade in architecture; an object that serves as a front-facing interface masking more complex underlying or structural code. A facade can:
  • improve the readability of a library by masking interaction with more complex components behind a single API
  • provide a context-specific interface to more generic functionality
  • serve as a launching point for a broader refactor of monolithic or tightly-coupled systems in favor of more loosely-coupled code
Developers often use the facade design pattern when a system is very complex or difficult to understand because the system has many interdependent classes or because its source code is unavailable. This pattern hides the complexities of the larger system and provides a simpler interface to the client. It typically involves a single wrapper class that contains a set of members required by the client.

Overview

Problems can the Facade design pattern solves

  1. To make a complex subsystem easier to use, a simple interface should be provided for a set of interfaces in the subsystem.
  2. The dependencies on a subsystem should be minimised.
A Facade is used when an easier or simpler interface to an underlying object is desired. Alternatively, an adapter can be used when the wrapper must respect a particular interface and must support polymorphic behaviour.

No comments:

Post a Comment