Tuesday, April 23, 2019

Facade Pattern Java Example

Facade Design Pattern Java Example

Facade Pattern is a structural design pattern. its deals with interfaces, not implementation.
As the name suggests structural pattern is used to form a larger object structure from many different objects. Fa├žade pattern is one such pattern which provides a simplified interface to a set of interfaces within a system and thus it hides the complexities of the subsystem from the client.
Facade Design Pattern hides the complexities of the system and provides an interface to the client from where the client can access the system.

The definition of Facade provided by Gang of Four book on Design Patterns states:
 Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.   

When To Use Facade Pattern :
The facade pattern is used when we have a complex system that we want to expose to clients in a simple way, or we want to make an external communication layer over an existing system which is incompatible with the system.
Facade deals with interfaces, not implementation. Its purpose is to hide internal complexity behind a single interface that appears simple on the outside.
Example : Suppose we have to generate report and we have two service to generate repote PDF or Excel. So we have to create one interface Report and its two implementation class ReportPDF and ReportExcel. So when user select either PDF or Excel so system will generate report of selected formate.

Related Tutorials

No comments:

Post a Comment