Re: Looking for best practice advice on data access for SMALL web sites - not enterprise



In article <OXfpk$smGHA.2056@xxxxxxxxxxxxxxxxxxxx>, sloan <sloan@xxxxxxxxx> writes

Factories allow you to work with Interfaces or Abstract classes.... instead
of the concrete class.

Here is a very rudamentary example:

http://support.microsoft.com/kb/308046

This would be the "key" method .. as I describe at my blog:

You pass it a key... (radio button value in the KB)
You don't care ~how / who populates the dataAdapter.. You only care that it
gets populated.

If you using oracle or access or sql server on the backend, you don't care.
All you want is a dataadapter.

OK, I see the logic in all this, but this is basically what I already do with my generic data access method. Granted it's a single method in a utility DLL, but the principle is the same. Yo pass it a request, and it passes back a DataReader. The code-behind file that calls it has no idea how it fills that DataReader, that's decided by the connection string, which only the method uses.

In what way would I benefit from moving away from this simple method to a more complex class? It seems that the class does basically the same thing.

To critique the article, I wouldn't send back a dataadapter, I'd send back
an IDataReader.

OK, well I already do that, so I scored one point ;-)

The "factory" says, .. "populate a IDataReader for me". You pass it a key
.. and it says "Ill use the key to populate the IDataReader with data from
an oracle database".

The design pattern isn't just for data base stuff. It has many items it can
address.

But its a start.

I'd look up "provider model"

110,000,000 results!!

"membership provider"

57,900,000 results!!

This is my problem with this stuff. There's so much written, but little that I can find that explains the basics in readable English.

<snip>
Ok, I've written a book now. I gotta get back to work.

I know how you feel. That's one reason why I have stuck with my current method for so long. It works, and I don't have time to read the vast amounts of info required to learn these sorts of patterns.

Good luck.

Thanks, I'll need it!!

--
Alan Silver
(anything added below this line is nothing to do with me)
.