façade pattern

Post on 09-Jan-2016

36 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

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

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

Motivation

Structuring a system into subsystems helps reduce complexity

Minimize communication dependencies between subsystems

Introduce a façade that provides a single simplified interface

Provides a single interface to clients

Example - Compiler

Scanner Parser ProgramNode BytecodeStream ProgramNodeBuilder

Compiler subsystem contains classes:

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

Compiler subsystem includes a Compiler class - unified interface

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

Structure

Benefits

Shields clients from subsystem components Promotes weak coupling between the

subsystem and clients Doesn’t prevent clients from accessing

subsystem classes if necessary

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

Sample Code

Sample Code

Sample Code

Sample Code

Sample Code

Related Patterns

Abstract Factory Mediator Singleton Adapter Decorator

Questions?

top related