Design patterns – Facade

A facade is an object that provides a simplified interface to a larger body of code, such as a class library. This pattern hides the complexities of the larger system and provides a simpler interface to the client. It typically involves a single wrapper class that contains a set of members required by client.

For example, let’s say we have three classes, A, B, and C, and that we need to call multiple functions from these classes.

Given the classes:

Let’s say that, for an update, we will need to do the following sequence:


Ok, this is too complicated for the user.

Let’s create a Facade class that he can use:

The user will now to know only that he can update whatever by calling update() on the Facade object.

The full code can be found at the following link:

You may also like...

Leave a Reply