Using the Adapter Pattern
page 2 of 8
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 35843/ 49

Example Services

The example services that we will use are two providers within the sample application included with this article.  The provider code exists in the same application, but in reality it would be a reference from a Dynamic Link Library (DLL), a web service reference or some other means.  But, for example purposes, let us look at two of the methods that would be commonly in the service.

Listing 1

namespace BooksExpress
{
  public class BooksProvider
  {
    public BookItem GetByISBN(string isbn){}
    public BookItem[]Search(string searchText, bool anyTerms, bool
      relativeMatching){}
  }
}
 
namespace ILuvBooks
{
  public static class BooksService
  {
    public static DataTable GetBookByISBN(string isbn){}
    public static DataTable GetBooksBySearch(string searchText, bool anyTerms){}
  }
}

The example above shows the code for the two fictitious companies that we will be working with in this example: BooksExpress and ILuvBooks.  As you can see, these two providers implement different approaches. The first uses a domain object to represent the book data, as well as using an instance of the class to provide the book data. The second class uses more of a procedural approach in creating a static class with static methods, returning a DataTable to the caller.  How do we calculate for this?  Welcome the adapter pattern.


View Entire Article

User Comments

Title: Great !!   
Name: Gourik kumar Bora
Date: 2011-05-12 2:09:23 AM
Comment:
thanks a lot Brian ....
Title: Excellent article   
Name: Chetan P
Date: 2008-08-18 6:01:55 AM
Comment:
This is an excellent article i read about adapter pattern. I wish if it was given with UML diagrams, it would more appropriate to understand at a glance.
Title: Great   
Name: vishal
Date: 2007-12-05 12:54:21 AM
Comment:
very easy to understand and really simple yet powerful post.
Title: good one   
Name: rakesh gurjar
Date: 2007-05-21 9:11:14 AM
Comment:
nice to understand concept of adapter pattern






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 9:01:49 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search