Home     RSSRSS

Façade Pattern

May 1, 2018 by kiranbadi1991 | Filed under Others.

Façade pattern is used to hide the complexity of the sub system and provide users with the simple and easy to use interface to consume.

Commonly used use cases for Façade are

  • Provide simple and easy to use interface to backend legacy system.
  • Sometimes used to build the public interface for users to consume.
  • To abstract the complexity of the system for simplicity and security
  • Depending on use case, it can also be used to improve performance by reducing frequent call invocation and providing remote client single point of access by grouping related functionality in the subset of classes.

Façade Pattern can be implemented for Pojo, stateful and stateless use cases. However for stateful classes it consumes the server resources and ties up to the client during invocation process. So one needs to careful that client do not take up too much of time for processing else server resources will be consumed. Generally if conversational state needs to be maintained then stateful façade can be used.

Generally complexity of the logic dictates the length and abstraction of the wrapper methods in the façade.

Facades can also be used to create factory methods.

Example of Facade can be.

public class Car {

public void 4CylinderEngine(){

	// Methods the exhibit behavior of 4 Cylinder
	}

public void 6CylinderEngine(){
		// Methods the exhibit behavior of 6 Cylinder
	}

}
 
// Using the facade

new Car.4CyclinderEngine();
new Car.6CyclinderEngine();


← Previous

Comments are disabled