tags:

views:

41

answers:

2

There are many classes having this provider suffix. (Data,membership,modelmetadata,...).

When should be a class called as a provider class ?

+4  A: 

Providers mostly are between your logic and data stores of any kind (database, xml, etc.). MSDN mentions:

Providers abstract storage media in much the same way that device drivers abstract hardware devices.

For more information: Microsoft ASP.NET 2.0 Providers: Introduction

For example: In stead of working with a database or XML, you want to work with flat file storage on a disk somewhere within your network. To manage this you build a custom provider and use it within your logic to save the data.

Joop
The reason they exist is to be replaced. Like I write a web application now that will map authentication and authorization to an application internal user store - and I can hook taht nicely into the provider model.
TomTom
+1  A: 

Here is description of provider pattern from MS (http://msdn.microsoft.com/en-us/library/ms972319.aspx):

The pattern itself is exceedingly simple and is given the name "provider" since it provides the functionality for an API. Defined, a provider is simply a contract between an API and the Business Logic/Data Abstraction Layer. The provider is the implementation of the API separate from the API itself. For example, the new Whidbey Membership feature has a static method called Membership.ValidateUser(). The Membership class itself contains no business logic; instead it simply forwards this call to the configured provider. It is the responsibility of the provider class to contain the implementation for that method, calling whatever Business Logic Layer (BLL) or Data Access Layer (DAL) is necessary.

There are some rules for how a provider behaves. A provider implementation must derive from an abstract base class, which is used to define a contract for a particular feature. For example, to create a membership provider for Oracle, you create a new class OracleMembershipProvider, which derives from MembershipProviderBase. The feature base class, for example, MembershipProviderBase, in turn derives from a common ProviderBase base class. The ProviderBase class is used to mark implementers as a provider and forces the implementation of a required method and property common to all providers. Figure 4 gives an example of the inheritance chain.

Andrew Bezzub