Writing a Provider for ASP.NET


When I started programming, some 20 years ago (damn, I feel old now) - we didn't have as many "toys" and "gadgets" as we do today. To be honest, back then, computer programming was so new that the most successful programmers were the ones that were able to use imagination to solve problems.

Today, things are very different. We have very solid Integrated Development Environments (IDEs) along with a myriad of best practices such as Design patterns.

I remember when OOP first came out, it was such a revolution that it even got some ink in newspapers (and not even in the tech section, but in the general section). Little did we know back then that OOP was still in its infancy and would evolve into what it is today where we would apply Patterns such as the Strategy Pattern and the Singleton Pattern.

While designing a good architecture with OOP is a very good idea, there is another pattern that I would like to discuss today: The Provider Pattern in ASP.NET.

A provider is essentially a window into some functionality. For example, I could design a Provider that handles authenticating users:

The Authentication Provider

What's clear about designing a provider is not to stop at the how but instead looking at the what.

Think about it this way:

  • How things work
  • What you want to do

How things work: Are we using this technology or that one? Are we using SQL to authenticate users or LDAP? Or maybe we will be using XML files, or perhaps another system such as a custom Web Service.

Beginning with Providers

Proper programming usually starts with admitting that you are trying to solve a problem, and not trying to see how you can justify using this cool technology and use it to try to solve a problem. So we aren't going to look at the What yet and instead look at the How

How What
We want to authenticate users, we want to get their e-mail address, we want to get their full name, we want to know if their account is active, etc Connect to SQL server, open an XML file, open an HTTP channel to a Web Service, open an LDAP connection to a Directory Server

MSDN - How to Write a Custom Provider

0 comments: