Facade Pattern falls under the Structural Pattern category of Design Patterns. As per GoF, Facade Pattern can be defined as "unified interface to a set of sub system. Facade defines high level interface that makes the sub systems easy to use".
Lets define the Facade Pattern with the help of an example as given below.
Lets take a scenario around Ticket Reservation System. Lets design a real world application called "Ticket Reservation System". This system is used to reserve tickets for Flight, Train, Bus modes of transport. So here the user needs to interact with Flight Reservation Sub system, Train Reservation Sub System, Bus Reservation Sub System etc. So lets define each of the Sub systems as given below
Flight Reservation Sub System:
Train Reservation Sub System :
Bus Reservation Sub System :
Now lets define a Facade which interact with all the above Sub systems so that all these sub systems are hidden from a client perspective. Here we have the feasibility to plug in more Sub systems into this picture
Ticket Reservation Facade:
Now lets once again define the high level interactions between the client, Facade and Sub systems as follows.
Please click the link for the Source code for the above Facade example... DOWNLOAD.
No comments:
Post a Comment