Docstoc

Lecture_4_-_Facade

Document Sample
Lecture_4_-_Facade Powered By Docstoc
					Software Design and Architecture
Facade Design Patterns


                         Muhammad Nasir
                           m.nasir@iiu.edu.pk
Facade

   Intent
       Provide a unified interface to a set of interfaces
        in a subsystem.
       Facade defines a higher-level interface that
        makes the subsystem easier to use.
Facade

   Motivation
Facade

   Compiler System
Facade

   Daily Life Example
      Automatic gas pumps can be very
      complex. There are many options on
      them: how to pay, the type of gas to
      use, watch an advertisement.
      Solution: One way to get a unified
      interface to the gas pump is to use a
      human gas attendant (Facade).
Facade

   Motivation
       Structuring a system into subsystems helps
        reduce complexity.
       The interface exposed by the classes in a
        subsystem or set of subsystems can become
        quite complex.
       One way to reduce this complexity is to
        introduce a facade object that provides a single,
        simplified interface to the more general facilities
        of a subsystem
Facade

   Applicability
    Use Facade design pattern…
     To provide a simple interface to a complex
      subsystem.
     To decouple the classes of the subsystem from
      its clients and other subsystems, thereby
      promoting subsystem independence and
      portability.
Facade

   Structure
Facade
   Participants
       Facade (Compiler)
           Knows which subsystem classes are responsible for a
            request.
           Delegates client requests to appropriate subsystem
            objects.
       Subsystem classes (Scanner, Parser etc.)
           Implement subsystem functionality.
           Handle work assigned by the Facade object.
           Have no knowledge of the facade; that is, they keep no
            references to it.
Facade

   Collaborations
       Clients communicate with the subsystem
        by sending requests to Facade, which
        forwards them to the appropriate
        subsystem objects.
       Clients that use the facade don't have to
        access its subsystem objects directly.
Facade

   Consequences
       Shielding Clients
           Reduces the number of objects clients need to deal with
       Promotes weak coupling
           Between subsystems and clients
           Although(!) components in the subsystem may be strongly
            coupled.
           Help layer the system (also prevents circular dependencies)
       But – permits direct use
           In case individual components offer meaningful service to
            clients – the Façade mediates, but does not block access.
Facade

   Related Patterns
       Usually only one Facade object is required.
        Thus Facade objects are often Singletons.
The End

   Thanks for listening
   Questions would be appreciated.

				
DOCUMENT INFO
Shared By:
Stats:
views:1
posted:4/26/2012
language:
pages:13
Description: software design and architecture