Skip to content

KishorNaik/Sol_Facade_Pattern_Typescript

Repository files navigation

Facade Pattern

The Facade Pattern is a structural design pattern that provides a simplified interface to a complex subsystem, making it easier for clients to interact with the system.

Intent

  • Provide a unified interface to a set of interfaces in a subsystem.

  • Reduce the complexity of interaction with the subsystem.

  • Decouple clients from the subsystem, promoting loose coupling.

Applicability

Use the Facade Pattern when:

  • You want to simplify the interface to a complex subsystem.

  • There are many dependencies between clients and the implementation classes of an abstraction.

  • You want to layer your subsystems and use facades to define entry points to each subsystem.

Structure

The Facade Pattern involves three primary components:

  • Facade: The simplified interface that interacts with the complex subsystem on behalf of the client.

  • Subsystem Classes: The complex classes that perform the actual work.

  • Client: The entity that uses the facade to interact with the subsystem.

Participants

  • Facade: Knows which subsystem classes are responsible for a request and delegates client requests to appropriate subsystem objects.

  • Subsystem Classes: Implement the subsystem functionality. They handle work assigned by the facade and have no knowledge of the facade.

Collaborations

  • Clients communicate with the subsystem by sending requests to the facade.

  • The facade forwards the requests to the appropriate subsystem objects.

  • Subsystem classes do the actual work and return results to the facade, which in turn returns the results to the clients.

Consequences

  • Reduces Complexity: Hides the details of the subsystem, making it easier to use.

  • Promotes Loose Coupling: Decouples clients from the subsystem, promoting modularity and ease of maintenance.

  • Improves Readability: Simplifies the code, improving readability and reducing the learning curve for new developers.

About

demo of Facade Pattern in Typescript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published