Session Facade Design Pattern

While developing software, it is very important to use proper design patterns. For learning design patterns, it's important to observe which design pattern properly fits our problem and how we will use the appropriate patterns. It's common to misuse design patterns on a problem. So, it's very important to find a proper design pattern for a given problem in software development.


Session Facade pattern is a part of the Structural Design Pattern of Gang of Four (GoF) Design Patterns. The facade pattern is useful when working with a large number of participated classes.

In a case when our application needs to communicate with multiple services or classes of other applications, the other application and its classes may not run on the local machine to which our application is running. Rather, they might be physically separated and running over a network.

If your classes talk to multiple other classes, there are lots of disadvantages,

  1. Classes are exposed to the inner details of the other application classes which means we are tightly coupled with other application components.

  2. We need to understand the complete process of the application components, methods, and dependencies which means we are exposed to the complexities of the application.

  3. If other applications are running on a different machine, to talk those objects, we need to make network calls many times. This increases the bandwidth usage and degrades the performances.

To overcome these disadvantages, we should never expose multiple services to the other applications; rather, we need to expose one high-level service over multiple cross-grained services. This way, the other applications can call only one network call to the high-level service (called Facade) which takes care of internally talking to multiple classes in providing the functionality.

The high-level service which we are exposing here is called "Session Facade" which reduces multiple network calls and optimizes the performance as well.

The facade design pattern is especially useful when wrapping subsystems which are not designed properly and not able to be refactored because the source code is unavailable on a local machine or the existing interface is used in many other processes.

Advantages of using Session Facade


  • Using Session Facade, we can increase the performance.
  • We can reduce the dependency of outside code on the internal working code, which provides more flexibility in application development.
  • Session Facade decouples the code which makes it easier to modify the system later.


 That's it. I hope you will find this article helpful while developing applications using design patterns.