Facade - PowerPoint PPT Presentation

About This Presentation
Title:

Facade

Description:

Provides a unified interface to a set of interfaces in a subsystem ... You want to provide a simple interface for a complex subsystem ... – PowerPoint PPT presentation

Number of Views:700
Avg rating:3.0/5.0
Slides: 11
Provided by: ericgoo
Learn more at: http://www.cs.rpi.edu
Category:
Tags: facade | subsystem

less

Transcript and Presenter's Notes

Title: Facade


1
Facade
  • Eric Goodnough

Software Design Documentation
2
About Facade
  • Structural Pattern
  • Provides a unified interface to a set of
    interfaces in a subsystem
  • Defines a higher-level interface that makes the
    subsystem easier to use

3
Structural Diagram
Client Classes
Facade
Subsystem Classes
4
Participants
  • Facade
  • Knows which parts of the subsystem are
    responsible for what
  • Delegates client requests to the appropriate
    objects in the subsystem
  • Subsystem classes
  • Implement subsystem functionality
  • Handle work assigned by the facade
  • Have no knowledge of the facade, since they keep
    no reference to it

5
Applicability
  • Use the facade structural pattern when
  • You want to provide a simple interface for a
    complex subsystem
  • There are many dependencies between the client
    and implementation classes
  • You want to layer your subsystems

6
Benefits
  • Reduces the number of objects the clients have to
    deal with
  • Promotes weak coupling between the subsystem and
    the clients
  • Doesnt prevent applications from using subsystem
    classes

7
Compiler Example
Compiler
  • Compiler Subsystem
  • Scanner
  • Parser
  • ProgramNode
  • ProgramNode Builder
  • CodeGenerator

Parser
Scanner
ProgramNodeBuilder
CodeGenerator
ProgramNode
8
Example Code (pg. 189-191)
  • Class Scanner //.
  • Class Parser //.
  • Class ProgramNodeBuilder //.
  • Class ProgramNode //.
  • Class CodeGenerator //.
  • Class Compiler //facade class
  • public
  • Compiler()
  • virtual void Compile(istream, BytecodeStream)

9
Example Code (cont.)
  • Void CompilerCompile(istream input,
    BytecodeStream output)
  • Scanner scanner(input)
  • ProgramNodeBuilder builder
  • Parser parser
  • parser.Parse(scanner, builder)
  • RISCCodeGenerator generator(output)
  • ProgramNode parseTree builder.GetRootNode()
  • parseTree-gtTraverse(generator)

10
  • Any Questions?
Write a Comment
User Comments (0)
About PowerShow.com