facadepattern

14
Design Patterns Facade Pattern (A Structural Pattern) Prsented By: Jainik Patel(112332) Darshan Darji(112333) Dhiraj Rajput(112338) Prashant Goswami(112344)

Upload: jainikpatel12

Post on 06-Nov-2014

170 views

Category:

Education


0 download

DESCRIPTION

Facade Pattern By Jainik Patel

TRANSCRIPT

Page 1: Facadepattern

Design PatternsFacade Pattern

(A Structural Pattern)

Prsented By:Jainik Patel(112332)Darshan Darji(112333)Dhiraj Rajput(112338)Prashant Goswami(112344)

Page 2: Facadepattern

FacadeA structural design pattern

• Decouples interface from implementation

Intent• To provide a unified interface to a set of

interfaces in a subsystem• To simplify an existing interface • Defines a higher-level interface that makes the

subsystem easier to use

Page 3: Facadepattern

Facade Problem & Solution

Subsystemclasses

Clientclasses

FACADE

Page 4: Facadepattern

Motivation• Structuring a system into subsystems helps

reduce complexity.

• A common design goal is to minimize the communication and dependencies between subsystems.

• One way to achieve this goal is to introduce a facade object that provides a single, simplified interface to the more general facilities of a subsystem.

Page 5: Facadepattern

ApplicabilityUse the Facade pattern when

Facade to decouple the subsystem for clients and other subsystems

To layer your subsystem. Use façade to define an entry point to each subsystem level. If subsystems are dependent, then you can simplify the dependencies between them by making them communicate with each other through their facades.

Page 6: Facadepattern

Facade Structure

Page 7: Facadepattern

ParticipantsFacade

knows which subsystem classes are responsible for a request.

delegates client requests to appropriate subsystem objects.

subsystem classesimplement subsystem functionality. handle work assigned by the Facade object.

Page 8: Facadepattern

CollaborationsClients communicate with the subsystem by

sending requests to Facade, which forwards them to the appropriate subsystem object(s). Although the subsystem objects perform the actual work, the facade may have to do work of its own to translate its interface to subsystem interfaces.

Page 9: Facadepattern

ConsequencesThe Facade pattern offers the following

benefits:

It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use.

It promotes weak coupling between the subsystem and its clients.

Help in layering the systems helps elements circular dependency.

Page 10: Facadepattern

Implementation• Sub System easier to use• Strongly Coupled.• We're going to create a MobileShope interface

and concrete classes implementing the MobileShope interface. A facade class ShopeKeeperFacade is defined as a next step.

• ShopeKeeperFacade class uses the concrete classes to delegates user calls to these classes FacadeClient, our Client class will use ShopeKeeperFacade class to show the results.

Page 11: Facadepattern

Example Class Diagram

Page 12: Facadepattern

Example Class Diagram

Page 13: Facadepattern

Facade Pattern – Related Pattern

– Abstract Factory Pattern

– Common Variations • Key: Don’t add new behavior, just simplify

interface to existing behavior

– Java API Usage• java.net.URL

– client can use it without being aware of classes that allow it to work

– client can use classes like URLConnection directly if they choose

Page 14: Facadepattern

THANK YOU