Facade 1 What is a facade? From Merriam-Webster Online 1 : the - - PowerPoint PPT Presentation

facade
SMART_READER_LITE
LIVE PREVIEW

Facade 1 What is a facade? From Merriam-Webster Online 1 : the - - PowerPoint PPT Presentation

Facade 1 What is a facade? From Merriam-Webster Online 1 : the front of a building ; also : any face of a building given special architectural treatment <a museum's east facade > 2 : a false, superficial, or artificial


slide-1
SLIDE 1

1

Facade

slide-2
SLIDE 2

5

What is a “facade”?

  • From Merriam-Webster Online
  • 1 : the front of a building ; also : any face of

a building given special architectural treatment <a museum's east facade>

  • 2 : a false, superficial, or artificial

appearance or effect

slide-3
SLIDE 3

6

  • Context:

 Often, an application contains several complex packages.  A programmer working with such packages has to manipulate many different classes

  • Problem:

 How do you simplify the view that programmers have of a complex package?

  • Forces:

 It is hard for a programmer to understand and use an entire subsystem  If several different application classes call methods of the complex package, then any modifications made to the package will necessitate a complete review of all these classes.

slide-4
SLIDE 4

7

Facade Intent Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use. Category? (Structural)

slide-5
SLIDE 5

8

Clients often need detailed knowledge of a subsystem to obtain the needed services.

Subsystem

slide-6
SLIDE 6

9

«PackageClass3» «PackageClass2» «PackageClass1»

*

RegularFlight

*

Person Airline

+findFlight() +makeBooking() +deleteBooking()

«Facade»

slide-7
SLIDE 7

10

Subsystem

A Façade can make it easier for clients to obtain the services that are needed.

Facade

slide-8
SLIDE 8

11

There are two characteristics that must be present to have a true Façade.

  • Unified interface
  • The clients know of one interface to call

for services

  • Reduces coupling to the subsystem, but

this is probably not the biggest benefit

  • Higher-level interface
  • Each service must provide more than a

client can get from a simple call to a subsystem object

  • Single-call "pass-through" functions are

not a higher-level interface

facadeFunction() { subsystemObject->aFunction() }

slide-9
SLIDE 9

12

Subsystem

Façades tend to quickly become bloated classes.

FacadeB FacadeA FacadeC

To eliminate this problem, there can be multiple types of Facades, each dealing with a logically related set of services that the subsystem provides to clients.

slide-10
SLIDE 10

13

There are some interesting questions about the Façade pattern.

  • Public or Private Subsystem (and implications)
  • Should a Façade be the only interface to a

subsystem?

  • Should the brave (or foolish) be able to call

directly into the subsystem?

  • What are the similarities between Façade

and Mediator with respect to a subsystem?