adapter design pattern
DESCRIPTION
Adapter Design Pattern ExplainedTRANSCRIPT
![Page 1: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/1.jpg)
Adapter Pattern
Shahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington
http://www.facebook.com/groups/netter/
![Page 2: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/2.jpg)
What is Adapter• A device for connecting pieces of equipment that cannot be connected directly
• An adapter allows classes to work together that normally could not because of incompatible interfaces
![Page 3: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/3.jpg)
Missing something??
![Page 4: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/4.jpg)
How does it work?
![Page 5: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/5.jpg)
When we need?
• Convert the interface of a class into another interface that client expects.• Allow classes to work together that couldn’t because of incompatible interfaces.• Future clients can be satisfied through the creation of additional concrete Adapter.• Adapter is meant to change the interface of an existing object. • A way to achieve OCP(Open/Closed Principle)
![Page 6: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/6.jpg)
Client Component
![Page 7: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/7.jpg)
Compo
nent/
Adap
tee
AdapterClient
![Page 8: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/8.jpg)
Adapters in the real world
![Page 9: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/9.jpg)
UML Structure
![Page 10: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/10.jpg)
Way to use (ref. DoFactory)
![Page 11: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/11.jpg)
Client
![Page 12: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/12.jpg)
Adapter
![Page 13: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/13.jpg)
Adaptee
![Page 14: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/14.jpg)
Another shocking example
![Page 15: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/15.jpg)
Adapter @.NET Framework• From .NET-based code you can easily call legacy COM objects and vice versa.
• Behind the scenes, Visual Studio® .NET create a Runtime Callable Wrapper (RCW) class. Inside the RCW, .NET specific format is converted into a format that the COM component expects and vise versa.
• Data Adapters adapts data from different source (SQL Server, Oracle, ODBC, OLE DB) to dataset.
• Different Data Adapter classes are usedSqlDataAdapterOdbcDataAdapterOleDbDataAdapter
![Page 16: Adapter Design Pattern](https://reader035.vdocuments.site/reader035/viewer/2022062704/5562d81cd8b42a6c498b51e0/html5/thumbnails/16.jpg)
Real World Scenario’s
• Most of the applications using third party libraries use adapters as a middle layer between the application and the 3rd party library.• Memory card reader software