A UML class diagram

We will now discuss the Façade pattern with the help of the following UML diagram:

A UML class diagram

As we observe the UML diagram, you'll realize that there are three main participants in this pattern:

  • Façade: The main responsibility of a façade is to wrap up a complex group of subsystems so that it can provide a pleasing look to the outside world.
  • System: This represents a set of varied subsystems that make the whole system compound and difficult to view or work with.
  • Client: The client interacts with the Façade so that it can easily communicate with the subsystem and get the work completed. It doesn't have to bother about the complex nature of the system.

You will now learn a little more about the three main participants from the data structure's perspective.

Façade

The following points will give us a better idea of Façade:

  • It is an interface that knows which subsystems are responsible for a request
  • It delegates the client's requests to the appropriate subsystem objects using composition

For example, if the client is looking for some work to be accomplished, it need not have to go to individual subsystems but can simply contact the interface (Façade) that gets the work done.

System

In the Façade world, System is an entity that performs the following:

  • It implements subsystem functionality and is represented by a class. Ideally, a System is represented by a group of classes that are responsible for different operations.
  • It handles the work assigned by the Façade object but has no knowledge of the façade and keeps no reference to it.

For instance, when the client requests the Façade for a certain service, Façade chooses the right subsystem that delivers the service based on the type of service.

Client

Here's how we can describe the client:

  • The client is a class that instantiates the Façade
  • It makes requests to the Façade to get the work done from the subsystems
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.18.4