façade pattern

18
Façade Pattern Jeff Schott CS590L Spring 2004

Upload: khuong

Post on 09-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

Façade Pattern. Jeff Schott CS590L Spring 2004. What is a façade?. 1) The principal face or front of a building 2) A false, superficial, or artificial appearance. What is the intent?. Provide a unified interface to a set of interfaces in a subsystem - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Façade Pattern

Façade Pattern

Jeff Schott

CS590L Spring 2004

Page 2: Façade Pattern

What is a façade?

1) The principal face or front of a building

2) A false, superficial, or artificial appearance

Page 3: Façade Pattern

What is the intent?

Provide a unified interface to a set of interfaces in a subsystem

Define a higher-level interface that makes a subsystem easier to use

Page 4: Façade Pattern

Motivation

Structuring a system into subsystems helps reduce complexity

Minimize communication dependencies between subsystems

Introduce a façade that provides a single simplified interface

Page 5: Façade Pattern

Provides a single interface to clients

Page 6: Façade Pattern

Example - Compiler

Scanner Parser ProgramNode BytecodeStream ProgramNodeBuilder

Compiler subsystem contains classes:

Page 7: Façade Pattern

Most clients don’t care about details like parsing and code generation

Compiler subsystem includes a Compiler class - unified interface

Page 8: Façade Pattern

Applicability

Provide a simple interface to a complex system

Reduce dependencies between clients and implementation classes

Layered subsystems - façade provides an entry point to each layer

Page 9: Façade Pattern

Structure

Page 10: Façade Pattern

Benefits

Shields clients from subsystem components Promotes weak coupling between the

subsystem and clients Doesn’t prevent clients from accessing

subsystem classes if necessary

Page 11: Façade Pattern

Implementation Considerations

Coupling between clients and the subsystem can be further reduced by making the façade an abstract class

Public v. Private subsystem classes

Page 12: Façade Pattern

Sample Code

Page 13: Façade Pattern

Sample Code

Page 14: Façade Pattern

Sample Code

Page 15: Façade Pattern

Sample Code

Page 16: Façade Pattern

Sample Code

Page 17: Façade Pattern

Related Patterns

Abstract Factory Mediator Singleton Adapter Decorator

Page 18: Façade Pattern

Questions?