Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Wed, 28 Jun 2006 12:24:27 -0400
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.
To critique the article, I wouldn't send back a dataadapter, I'd send back
an IDataReader.
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" "membership provider"
This is an implementation of the Factory Design Pattern. MS has defined an
abstract class. To get users/roles etc. They also provide 1 (one)
implementation.
However, if you'd like to roll your own Membership Provider, you extend the
base/abstract class. and fill in the methods.
Then you set up your web.config file to use your custom implementation.
Behind the scenes, (based on the xml in the web config), Microsoft uses
reflection to instantiate your object. through a factory.
this would related to me example (blog) which uses a config file for the
Simple Factory.
the factory will create either (1) Microsoft's version of the membership
provider OR (2) my custom implementation .. and return it... AS THE
BASE/ABSTRACT class.
the outside world only knows about the base/abstract class.. it doesn't know
specifically about my custom class, or the microsoft default implmentation.
it doesn't care.
it only cares that it has ~something which extended the base class.
...
Ok, I've written a book now. I gotta get back to work.
Good luck.
"Alan Silver" <alan-silver@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:VdHNr4ACraoEFwpc@xxxxxxxxxxxxxxxxxxxxxx
In article <Odqg5IimGHA.748@xxxxxxxxxxxxxxxxxxxx>, sloanserious
<sloan@xxxxxxxxx> writes
<snip>
In my examples, I do not use a strongly typed dataset.
Developing those objects and collections takes time. However, for a
functionality.application, that's probably the way to go.
OK, forgive me for flogging this one, but I really want to understand
this properly. Why is this the way to go? What advantage does it have
over a strongly typed dataset?
Using the strongly typed datasets kinda of give you the same
ofBut its (my take) kind of the po's mans way of doing it.
Again, why? I'm not saying you're wrong, I just want to know why. I'm
really genuinely here to learn best practices, but I want to understand
why something is best, not just do it 'cos someone said that's better
;-)
<snip>
That's my take. I can't prove it. I can only offer advice.
That's OK, I came here for advice and I'm happy to hear it. I only ask
back on it to try and get it clear. I'm not saying you're wrong.
//
but
would modestly claim that I do not write spaghetti code.
//
Do you ever watch "The Office" on NBC?
Nah, don't have a TV. Can't stand them.
<snip>
3 years ago, I thought I was a really good developer. That I didn't do
stupid stuff. I mean, I could wrap my arms around a business problem and
get it solved.
OK, right off let me say I don't consider myself "really good." I would
like to consider myself capable and fairly good, but really good? Nah.
<snip>
My non technical advice is that.. sometimes its hard to be self-aware,
especially in more isolated environments. I'm not trying to attack, I'm
just letting you know as I look back, that's how I feel, mainly because
the boat I was in myself.
That's fine, I appreciate the feedback ;-)
OK, so having got this far, I could do with some guidance. Looking at
that site, it looks way above my head. I wouldn't know where to start.
Furthermore, the factory method that you mentioned looks like a very
complex way to do a simple job. What's the benefit in doing it this way?
I know I'm asking a big question here, but as a newbie to the idea of
design patterns, I can't see what they offer me. Why would I invest so
much time learning and implementing something so complex for a simple
job like grabbing a datareader full of product names?
Again, not criticising, just trying to understand.
You might want to try looking at the source code of
http://www.eecs.wsu.edu/paint.net/
Paint.NET
That is a pretty well designed application which does some serious stuff.
I'm not omniscient, I'm just offering my advice.
That's what I asked for ;-)
Good luck with your pursuit.
Thanks. Any further advice and comments welcome.
--
Alan Silver
(anything added below this line is nothing to do with me)
.
- Follow-Ups:
- References:
- Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: Alan Silver
- Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: sloan
- Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: Alan Silver
- Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: sloan
- Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- From: Alan Silver
- Looking for best practice advice on data access for SMALL web sites - not enterprise
- Prev by Date: Re: Problem with Javascript in a UserControl
- Next by Date: Re: Getting a random letter.
- Previous by thread: Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- Next by thread: Re: Looking for best practice advice on data access for SMALL web sites - not enterprise
- Index(es):