Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Design & Documentation

Similar presentations


Presentation on theme: "Software Design & Documentation"— Presentation transcript:

1 Software Design & Documentation
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 Subsystem classes
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 Doesn’t prevent applications from using subsystem classes

7 Compiler Example 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 Compiler::Compile(istream& input, BytecodeStream& output) { Scanner scanner(input); ProgramNodeBuilder builder; Parser parser; parser.Parse(scanner, builder); RISCCodeGenerator generator(output); ProgramNode* parseTree = builder.GetRootNode(); parseTree->Traverse(generator); }

10 Any Questions?


Download ppt "Software Design & Documentation"

Similar presentations


Ads by Google