Design Facade
-
Upload
vipin-vasudevan -
Category
Documents
-
view
257 -
download
0
Transcript of Design Facade
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 1/18
Facade Design P
By VI
2
attern
PIN T.M
13H112049G
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 2/18
Structural Patte
● Structural patterns are coand objects are composestructures.Structural clas
compose interfaces or im ● g . aca e, apter, ec
ns
cerned with how classesto form largerpatterns use inheritance to
lementations rator
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 3/18
Structure
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 4/18
Purpose
Provide a unified interfacesubsystem. Facade definethat makes the subsyste
o a set of interfaces in as a higher-level interfaceeasier to use.
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 5/18
Motivation
Reduce Complexity: Introdprovides a single, simplifiegeneral facilities of a subsy
uce a facade object thatinterface to a more
tem.
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 6/18
Applicability
● You want to provide a sisubsystem.A facade can pof the subsystem that is g
clients. Only clients need
● You want to layer your su
ple interface to a complexrovide a simple default viewod enough for most
ing more customizability.
systems.
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 7/18
=
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 8/18
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 9/18
Collabarations
Clients communicate witrequests to Facade, whicappropriate subsystem o
subsystem objects perfor
interface to subsystem in
Clients that use the facasubsystem objects directl
the subsystem by sendingforwards them to the
ject(s). Although the
the actual work, the
erfaces.
e don't have to access its.
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 10/18
Sub classes
class A:def Do_A_Task(self):
print "Executing A"
class B:def Do_B_Task(self):
print "Executing B"
class C:def Do_C_Task(self):
print "Executing C"
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 11/18
class Facade:
def doAllTask(self):
#Creates objects of A,B an
Aobj.Do_A_Task()
Bobj.Do_B_Task(). _ _
if __name__=="__main__":
Facadeobj=Facade()Facadeobj.doAllTask()
C.(Aobj,Bobj,Cobj)
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 12/18
Real Life Exampl es
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 13/18
Compiler
Consistes of componentsanalyzer,parser etc.
In most cases client is lea
individual components.It nter ace comp e w c
such as a lexical
st concerned about these
would like to have aoes a t e tas s
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 14/18
Online Travel B oking Website
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 15/18
public class HotelBooker{public ArrayList<Hotel> getHo
to){//returns hotels available in th}}
public class FlightBooker
public ArrayList<Flight> getFli{//returns flights available in t
}}
elNamesFor(Date from, Date
particular date range
ghtsFor(Date from, Date to)
he particular date range
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 16/18
public class TravelFacade{private HotelBooker hotelBooprivate FlightBooker flightBopublic void getFlightsAndHot{
ArrayList<Flight> flights = fto);
ArrayList<Hotel> hotels = hto);//process and return
}}public class Client
{ public static void main(String[{TravelFacade facade = new T
facade.getFlightsAndHotel
}}
er; ker;
ls(Date from, Data to)
ightBooker.getFlightsFor(from,
telBooker.getHotelsFor(from,
args)
avelFacade();(from, to);
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 17/18
Consequences
Shielding clients from sucoupling b/w subsystem
It shields clients from sut ere y re ucing t e nudeal with and making th
Does not prevent clientsunderlying classes
system promotes weaknd the clients.
system components,er o o jects t at c ients
subsystem easier to use
rom accessing the
8/12/2019 Design Facade
http://slidepdf.com/reader/full/design-facade 18/18
References Design Patterns: Elements o
Software,Eric Gama et al, IS
http://javapapers.com/desi
pattern/
http://en.wikipedia.org/wiki
http://www.tutorialspoint.c
pattern.htm
Reusable Object-Oriented
N: 0201633612
n-patterns/facade-design-
/Facade_pattern
m/design_pattern/facade_