Facade Pattern Tutorial
This tutorial is aimed to guide the definition and application of Gang of Four (GoF) facade design pattern. By reading this tutorial, you will know how to develop a model for the facade pattern, and how to apply it in practice.
Modeling a Design Pattern with a Class Diagram
- Create a new project named Design Patterns.
- Create a class diagram named Facade.

- Select Package from the diagram toolbar. Press on the diagram and drag it towards the bottom right to form a package representing a subsystem.

- Name the package subsystem.

- Select Class from the diagram toolbar. Click inside the subsystem to create a class. Name it Facade.

- Right-click on Facade and select Add > Operation from the popup menu.

- Name the operation ClientRequest. Note that it must be a public operation that enables classes external to the subsystem to access it.

Defining a Pattern
- Select everything on the class diagram.

- Right-click on the Singleton class and select Define Design Pattern... from the popup menu.

- In the Define Design Pattern dialog box, specify the pattern name as Facade. Keep the file name as is. Click OK to proceed.

Applying a Design Pattern to a Class Diagram
In this section, we will apply the facade pattern in modeling a code generator.
- Create a new project named Code Generator.
- Create a class diagram named Generator.
- Right-click on the class diagram and select Utilities > Apply Design Pattern... from the popup menu.

- In the Design Pattern dialog box, select Facade from the list of patterns.

- Select subsystem in the overview pane.

- At the bottom pane, rename subsystem to generator. Rename Facade to CodeGenerator and ClientRequest to generate.

- Click OK to apply the pattern. This is the diagram obtained:

- We need to fill in the subsystem. Move the mouse cursor over the CodeGenerator class and drag out Aggregation > Class to an empty region in the package to create a class. Name the class ClassBuilder.

- Right-click on ClassBuilder and select Open Specification from the popup menu.

- In the Class Specification, set Visibility to package. Click OK to confirm.

- Repeat steps 8 to 10 to create classes AttributeBuilder and OperationBuilder.
