Download presentation
Presentation is loading. Please wait.
1
Façade Pattern Jeff Schott CS590L Spring 2004
2
What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance
3
What is the intent? n Provide a unified interface to a set of interfaces in a subsystem n Define a higher-level interface that makes a subsystem easier to use
4
Motivation n Structuring a system into subsystems helps reduce complexity n Minimize communication dependencies between subsystems n Introduce a façade that provides a single simplified interface
5
Provides a single interface to clients
6
Example - Compiler n Scanner n Parser n ProgramNode n BytecodeStream n ProgramNodeBuilder Compiler subsystem contains classes:
7
n Most clients don’t care about details like parsing and code generation n Compiler subsystem includes a Compiler class - unified interface
8
Applicability n Provide a simple interface to a complex system n Reduce dependencies between clients and implementation classes n Layered subsystems - façade provides an entry point to each layer
9
Structure
10
Benefits n Shields clients from subsystem components n Promotes weak coupling between the subsystem and clients n Doesn’t prevent clients from accessing subsystem classes if necessary
11
Implementation Considerations n Coupling between clients and the subsystem can be further reduced by making the façade an abstract class n Public v. Private subsystem classes
12
Sample Code
17
Related Patterns n Abstract Factory n Mediator n Singleton n Adapter n Decorator
18
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.