91-9990449935 0120-4256464 |
Facade PatternA Facade Pattern says that just "just provide a unified and simplified interface to a set of interfaces in a subsystem, therefore it hides the complexities of the subsystem from the client". In other words, Facade Pattern describes a higher-level interface that makes the sub-system easier to use. Practically, every Abstract Factory is a type of Facade. Advantage of Facade Pattern
Usage of Facade Pattern:It is used:
Example of Facade PatternLet's understand the example of facade design pattern by the above UML diagram. UML for Facade Pattern:Implementation of above UML:Step 1Create a MobileShop interface. File: MobileShop.java
Step 2Create a Iphone implementation class that will implement Mobileshop interface. File: Iphone.java
Step 3Create a Samsung implementation class that will implement Mobileshop interface. File: Samsung.java
Step 4Create a Blackberry implementation class that will implement Mobileshop interface . File: Blackberry.java
Step 5Create a ShopKeeper concrete class that will use MobileShop interface. File: ShopKeeper.java
Step 6Now, Creating a client that can purchase the mobiles from MobileShop through ShopKeeper. File: FacadePatternClient.java
Output
Next TopicFlyweight Pattern
|