SlideShare a Scribd company logo
1 of 18
04 Adapter and Façade Pattern Design Patterns © Prafulla Paraskar 2010
Adapter Structural Design Pattern © Prafulla Paraskar 2010
Definition The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface. (wikipedia) © Prafulla Paraskar 2010
Adapter Pattern – Explained (1/2) © Prafulla Paraskar 2010
Adapter Pattern – Explained (2/2)  An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface. The adapter translates calls to its interface into calls to the original interface, and the amount of code necessary to do this is typically small. The adapter is also responsible for transforming data into appropriate forms. © Prafulla Paraskar 2010
Adapter Pattern – Types of Adapters Class adapter Simple and versatile, invisible to the client. Object adapter Extensible to subclasses of the adapter. Two-way adapter Enables different clients to view an object differently. Pluggable adapter Presence of adapter is transparent; it can be put in and taken out. Several adapter can be active. © Prafulla Paraskar 2010
Adapter Pattern – UML Diagram © Prafulla Paraskar 2010
Adapter Pattern – Real World Samples AC adaptors Car charger for mobile phones COM InterOp in .NET SQLAdapter in .NET © Prafulla Paraskar 2010
Adapter Pattern – Guidelines You have : A domain specific interface. A Class to connect to with a mismatching interface. You Want : Create a reusable class to cooperate with yet-to-be-built classes. Change the names of methods as called and as implemented. Support different sets of methods for different purposes. © Prafulla Paraskar 2010
Facade Structural Design Pattern © Prafulla Paraskar 2010
Definition A facade is an object that provides a simplified interface to a larger body of code, such as a class library (wikipedia). © Prafulla Paraskar 2010
Façade Pattern – Explained (1/2) © Prafulla Paraskar 2010
Façade Pattern – Explained (2/2) The name is by analogy to an architectural facade. A facade can: make a software library easier to use and understand and test, since the facade has convenient methods for common tasks. make code that uses the library more readable, for the same reason. reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system. wrap a poorly-designed collection of APIs with a single well-designed API (as per task needs). © Prafulla Paraskar 2010
Façade Pattern – Types of Adapters Opaque Subsystem operations can only be called through the Façade. Transparent Subsystem operations can be called directly as well as through the Façade. Singleton Only one instance of the Façade is meaningful. © Prafulla Paraskar 2010
Façade Pattern – UML Diagram © Prafulla Paraskar 2010
Façade Pattern – Real World Samples Wedding planners / Event management. DirectX / OpenGL Online bill payment Macros in MS Office © Prafulla Paraskar 2010
Façade Pattern – Guidelines When: A system has several identifiable subsystems and: The abstractions and implementations of a subsystem are tightly coupled. The system evolves and gets more complex, but early adapters might want to retain their simple views. You want to provide alternative novice, intermediate and power user interfaces. There is a need for an entry point to each level of layered software.  © Prafulla Paraskar 2010
Thank you! http://geekswithblogs.net/technomad Presentation by Prafulla Paraskar  prafulla.paraskar@s1.com © 2010 S1 India Pvt. Ltd. Presentation by Prafulla Paraskar  eprafulla@gmail.com © 2010  Prafulla Paraskar

More Related Content

What's hot

Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
Manoj Kumar
 
Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603
melbournepatterns
 
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and MobileModern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Dan Mohl
 

What's hot (20)

Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
 
Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603
 
Adapter design-pattern2015
Adapter design-pattern2015Adapter design-pattern2015
Adapter design-pattern2015
 
Bridge
BridgeBridge
Bridge
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
Facade design pattern
Facade design patternFacade design pattern
Facade design pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Knockout.js components&routing
Knockout.js components&routingKnockout.js components&routing
Knockout.js components&routing
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and MobileModern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
 
Mule edifact module
Mule edifact moduleMule edifact module
Mule edifact module
 

Viewers also liked

Design Patterns
Design PatternsDesign Patterns
Design Patterns
soms_1
 
Code Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design PatternsCode Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design Patterns
Deon Meyer
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
Krazy Koder
 
Presentation on townplanning of irfhaa fathe (1)
Presentation on townplanning of irfhaa fathe (1)Presentation on townplanning of irfhaa fathe (1)
Presentation on townplanning of irfhaa fathe (1)
Shiek Fathe
 
Proxy & adapter pattern
Proxy & adapter patternProxy & adapter pattern
Proxy & adapter pattern
babak danyal
 
Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)
APU
 
Adapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListViewAdapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListView
Yuki Anzai
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
achraf_ing
 

Viewers also liked (20)

Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Code Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design PatternsCode Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design Patterns
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapter
 
Design Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight PatternDesign Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight Pattern
 
Presentation on townplanning of irfhaa fathe (1)
Presentation on townplanning of irfhaa fathe (1)Presentation on townplanning of irfhaa fathe (1)
Presentation on townplanning of irfhaa fathe (1)
 
Leads facade- Design Develope Deliver
Leads facade- Design Develope DeliverLeads facade- Design Develope Deliver
Leads facade- Design Develope Deliver
 
Design pattern part 1
Design pattern   part 1Design pattern   part 1
Design pattern part 1
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Proxy & adapter pattern
Proxy & adapter patternProxy & adapter pattern
Proxy & adapter pattern
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
 
Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)
 
Command and Adapter Pattern
Command and Adapter PatternCommand and Adapter Pattern
Command and Adapter Pattern
 
Adapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListViewAdapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListView
 
Chandigarh town planning final 24.12.16
Chandigarh town planning final 24.12.16Chandigarh town planning final 24.12.16
Chandigarh town planning final 24.12.16
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
Android adapters
Android adaptersAndroid adapters
Android adapters
 

Similar to Design Patterns - 04 Adapter and Facade Pattern

Adapter Pattern
Adapter PatternAdapter Pattern
Adapter Pattern
Monjurul Habib
 

Similar to Design Patterns - 04 Adapter and Facade Pattern (20)

As 400
As 400As 400
As 400
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Adapter Pattern
Adapter PatternAdapter Pattern
Adapter Pattern
 
Oracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best PracticesOracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best Practices
 
Oracle ADF Overview for Beginners
Oracle ADF Overview for BeginnersOracle ADF Overview for Beginners
Oracle ADF Overview for Beginners
 
Oracle ADF Architecture TV - Design - ADF Reusable Artifacts
Oracle ADF Architecture TV - Design - ADF Reusable ArtifactsOracle ADF Architecture TV - Design - ADF Reusable Artifacts
Oracle ADF Architecture TV - Design - ADF Reusable Artifacts
 
Systems Archticture
Systems ArchtictureSystems Archticture
Systems Archticture
 
J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native Developer
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF
 
ModelTalk - When Everything is a Domain Specific Language
ModelTalk - When Everything is a Domain Specific LanguageModelTalk - When Everything is a Domain Specific Language
ModelTalk - When Everything is a Domain Specific Language
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
 
Asp.NETZERO - A Workshop Presentation by Citytech Software
Asp.NETZERO - A Workshop Presentation by Citytech SoftwareAsp.NETZERO - A Workshop Presentation by Citytech Software
Asp.NETZERO - A Workshop Presentation by Citytech Software
 
Distributed system architecture
Distributed system architectureDistributed system architecture
Distributed system architecture
 
DDD
DDDDDD
DDD
 
OpenFlow/SDN activities of NTT Communications
OpenFlow/SDN activities of NTT CommunicationsOpenFlow/SDN activities of NTT Communications
OpenFlow/SDN activities of NTT Communications
 
Reducing External Risk
Reducing External RiskReducing External Risk
Reducing External Risk
 
C++ N Pv2
C++ N Pv2C++ N Pv2
C++ N Pv2
 
C#Portfolio
C#PortfolioC#Portfolio
C#Portfolio
 

Recently uploaded

一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
wpkuukw
 
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
eeanqy
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
tbatkhuu1
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
home
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
amitlee9823
 
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men 🔝dharamshala🔝 ...
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men  🔝dharamshala🔝  ...➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men  🔝dharamshala🔝  ...
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men 🔝dharamshala🔝 ...
amitlee9823
 
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 

Recently uploaded (20)

HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
怎样办理伯明翰大学学院毕业证(Birmingham毕业证书)成绩单留信认证
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls AgencyHire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
 
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptx
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
Sector 104, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 104, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 104, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 104, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men 🔝dharamshala🔝 ...
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men  🔝dharamshala🔝  ...➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men  🔝dharamshala🔝  ...
➥🔝 7737669865 🔝▻ dharamshala Call-girls in Women Seeking Men 🔝dharamshala🔝 ...
 
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Jp Nagar ☎ 7737669865 🥵 Book Your One night Stand
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 

Design Patterns - 04 Adapter and Facade Pattern

  • 1. 04 Adapter and Façade Pattern Design Patterns © Prafulla Paraskar 2010
  • 2. Adapter Structural Design Pattern © Prafulla Paraskar 2010
  • 3. Definition The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface. (wikipedia) © Prafulla Paraskar 2010
  • 4. Adapter Pattern – Explained (1/2) © Prafulla Paraskar 2010
  • 5. Adapter Pattern – Explained (2/2)  An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface. The adapter translates calls to its interface into calls to the original interface, and the amount of code necessary to do this is typically small. The adapter is also responsible for transforming data into appropriate forms. © Prafulla Paraskar 2010
  • 6. Adapter Pattern – Types of Adapters Class adapter Simple and versatile, invisible to the client. Object adapter Extensible to subclasses of the adapter. Two-way adapter Enables different clients to view an object differently. Pluggable adapter Presence of adapter is transparent; it can be put in and taken out. Several adapter can be active. © Prafulla Paraskar 2010
  • 7. Adapter Pattern – UML Diagram © Prafulla Paraskar 2010
  • 8. Adapter Pattern – Real World Samples AC adaptors Car charger for mobile phones COM InterOp in .NET SQLAdapter in .NET © Prafulla Paraskar 2010
  • 9. Adapter Pattern – Guidelines You have : A domain specific interface. A Class to connect to with a mismatching interface. You Want : Create a reusable class to cooperate with yet-to-be-built classes. Change the names of methods as called and as implemented. Support different sets of methods for different purposes. © Prafulla Paraskar 2010
  • 10. Facade Structural Design Pattern © Prafulla Paraskar 2010
  • 11. Definition A facade is an object that provides a simplified interface to a larger body of code, such as a class library (wikipedia). © Prafulla Paraskar 2010
  • 12. Façade Pattern – Explained (1/2) © Prafulla Paraskar 2010
  • 13. Façade Pattern – Explained (2/2) The name is by analogy to an architectural facade. A facade can: make a software library easier to use and understand and test, since the facade has convenient methods for common tasks. make code that uses the library more readable, for the same reason. reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system. wrap a poorly-designed collection of APIs with a single well-designed API (as per task needs). © Prafulla Paraskar 2010
  • 14. Façade Pattern – Types of Adapters Opaque Subsystem operations can only be called through the Façade. Transparent Subsystem operations can be called directly as well as through the Façade. Singleton Only one instance of the Façade is meaningful. © Prafulla Paraskar 2010
  • 15. Façade Pattern – UML Diagram © Prafulla Paraskar 2010
  • 16. Façade Pattern – Real World Samples Wedding planners / Event management. DirectX / OpenGL Online bill payment Macros in MS Office © Prafulla Paraskar 2010
  • 17. Façade Pattern – Guidelines When: A system has several identifiable subsystems and: The abstractions and implementations of a subsystem are tightly coupled. The system evolves and gets more complex, but early adapters might want to retain their simple views. You want to provide alternative novice, intermediate and power user interfaces. There is a need for an entry point to each level of layered software. © Prafulla Paraskar 2010
  • 18. Thank you! http://geekswithblogs.net/technomad Presentation by Prafulla Paraskar prafulla.paraskar@s1.com © 2010 S1 India Pvt. Ltd. Presentation by Prafulla Paraskar eprafulla@gmail.com © 2010 Prafulla Paraskar