facade

Type of the pattern:

The Facade design pattern is a structural design patterns (design pattern that ease the design by identifying a simple way to realize relationships between entities.)

Problem it solves:

The Façade design pattern provides a unified interface to a set of interfaces in a system. Façade defines a higher level interface that makes the subsystem easier to use.

 

facade

The Facade design pattern simplifies the interface to a complex system; because it is usually composed of all the classes which make up the subsystems of the complex system.

Façade makes the API and libraries easier to use which is good for maintenance and readability. It can also collate and abstract various poorly designed APIs with a single simplified API.

It also reduces dependencies of the external code on the inner working of the libraries and thus providing flexibility.

facadepattern1

In above example there are many things happening behind the scene in account creation which Action class/Servlet/Controller is completely unaware of. Action/Servlet/controller which is adapter for incoming http request interacts with very simple method createAccount in AccountService. Method signature is as below

public createAccount(long accountId, long customerId, double initialBalance)

Since there is only one point of contact for account creation in the form of createAccount method, it becomes very easy to change account creation implementation without affecting any client.

Facade Pattern

Post navigation


Leave a Reply

Your email address will not be published. Required fields are marked *