Monday 4 November 2013

Provider vs Adapter Design Pattern

1.       Provider pattern and Adapter pattern are same, as they adapt the different data sources APIs to be used uniformly for .NET applications. .NET provider for SQL server adapts the SQL server APIs to be used uniformly across the .NET applications. .NET provider for Oracle adapts the Oracle APIs to use uniformly for .NET application. Adapter seems to be a small concept like a class. But in case of provider, this adapter grows to full blown API or Library, therefore these are called Providers. They provide access to the particular data source.

1.       CASE 1: (Client application has upper hand) (We are coding the client application and we want to reuse the existing legacy or incompatible API or Library) Adapter or wrapper is a class that wraps a legacy or incompatible API or Library and exposes that API or Library in an interface that the client code expects. Adapt the API or Library in a way so that it could be used by client. CASE 2: (API or Library application has upper hand) (We are coding the API or Library and we want it to be reused by all future expected clients) Adapter or wrapper interface is exposed by the API or Library; all interested clients implement that interface exposed in order to use that API or Library.

No comments:

Post a Comment