Facade Pattern
Software Engineering(CS3011E)
Winter 2025-2026
Department of Computer Science and
Engineering, NIT Calicut
Instructor: Dr. Sourav Biswas
1
Taxonomy of GoF Patterns (23 Patterns)
2
Facade Pattern
Problem: How to avail services from a large
number of classes present in a package?
Context: A package is a cohesive set of classes:
Example: RDBMS interface package
DBA
Solution: A facade class (e.g. DBfacade) is
created to provide a common interface to the
services offered by the package.
3
Facade (Non software example)
Provides a unified
interface to a set
of classes in a
system.
Ordering Billing Shipping
4
Facade
R1 R2 R3 R1 R2 R3
Service Service
Package Package
S1 S2 S1 S2
Facade
S3 S4 S3 S4
R4 R5 R4 R5
(a) Service invocation without a façade (b) Service invocation using a façade class
5
Before and After Using Facade
DBQ Client Client B
Client A
A
Database
DBW Facade
Client B
DBR DBQ DBW DBR
Before Facade After Facade
6
Facade: Structure
Package
Facade
subsystem classes
A B C
E
D F G
7
Facade Pattern Example: Compiler
Compiler
Compile()
Scanner Token
CodeGenerator Parser
ProgNodeBuilder
RISCCG
ProgNode
StackMachineCG
Statement Node
Expression Node
Compiler Subsystem Classes Variable Node 8
Façade Example: Bank Package
Bank
AccountService
createAccount(…)
deposit(…)
withdraw(…)
Façade
TransactionService
createAccount(…)
deposit(…) addTransaction(…)
withdraw(…)
addTransaction(…)
applyForLoan(…)
LoanService
applyForLoan(…)
…
9
Façade: Bank Example
public class BankFaçade { public withdraw(int accountId,
float amount) {
private AccountService [Link](accountId
accountService; , amount);
private TransactionService }
transactionService;
public addTransaction(Transaction
private LoanService loanService; tx) {
[Link](
public addAccount(Account account) { tx);
[Link](account); }
} public applyForLoan(Customer cust,
public deposit(int accountId, float LoanDetails loan) {
[Link](cust, loan);
amount) {
}
[Link](accountId,
amount); }
}
10
Discussions on Façade Pattern
Clients communicate only
with the Façade:
Façade forwards each request to the appropriate
subsystem object(s).
Promotes low coupling; clients need to know only
about the Façade.
A Façade often does little more work than
simply delegating requests to other classes
inside the package! 11
Discussions on Façade Pattern
Although subsystem objects perform
actual work:
Façade may have to translate between
subsystem interfaces.
Clients are aware of only the Façade:
Don’t have to directly access any other
objects in the package.
12