adapter pattern

16
Adapter Pattern Shahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/

Upload: monjurul-habib

Post on 25-May-2015

321 views

Category:

Technology


3 download

DESCRIPTION

1. Adapter PatternShahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/ 2. 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 3. Missing something?? 4. How does it work? 5. 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) 6. Client Component 7. Client AdapterComponent/ Adaptee 8. Adapters in the real world 9. UML Structure 10. Way to use (ref. DoFactory) 11. Client 12. Adapter 13. Adaptee 14. Another shocking example 15. 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 usedSqlDataAdapterOdbcDataAdapterOleDbDataAdapter 16. 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.

TRANSCRIPT

Page 1: Adapter Pattern

Adapter Pattern

Shahriar Iqbal Chowdhury & Monjurul Habib                           Code Name: Remington

               http://www.facebook.com/groups/netter/

Page 2: Adapter Pattern

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 Pattern

            Missing something??

Page 4: Adapter Pattern

           How does it work?

Page 5: Adapter Pattern

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 Pattern

Client Component

Page 7: Adapter Pattern

Compo

nent/ 

Adap

tee

AdapterClient

Page 8: Adapter Pattern

Adapters in the real world

Page 9: Adapter Pattern

UML Structure

Page 10: Adapter Pattern

Way to use (ref. DoFactory)

Page 11: Adapter Pattern

Client

Page 12: Adapter Pattern

Adapter

Page 13: Adapter Pattern

Adaptee

Page 14: Adapter Pattern

Another shocking example

Page 15: Adapter Pattern

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 Pattern

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