Using a Singleton class for data services

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know if implementing a Singleton design pattern class to be used as a data access component would make for a solid architecture for an enterprise-wide .NET system?

I'm wondering if having a single point of entry won't become a bottle-neck and reduce performance.

If anyone has any information pertaining to Singleton classes, I'd be grateful
 
KMiller:
KMiller said:
Does anyone know if implementing a Singleton design pattern class to be
used as a data access component would make for a solid architecture for an
enterprise-wide .NET system?
I'm wondering if having a single point of entry won't become a bottle-neck and reduce performance..

If anyone has any information pertaining to Singleton classes, I'd be grateful.

K

On the contrary, I think a Singleton is not the pattern of choice here,
particularly in an enterprise environment. I think an Abstract Factory
pattern lends itself well here
http://www.vbdotnetheaven.com/Code/Jun2003/2043.asp mainly because in the
enterprise, you may be accessing different databases. You may get some data
from a web service, Oracle DB, Sql Server Access or whatever. Of course it
would depend on how you implemented things and your particular situation but
in general, you can see how a Singleton wouldn't be the way to go in the
above scenario Take a look at Microsoft's DAAB for a good example
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp
and if you want a really cool derivative which is multithreaded...
http://www.codeproject.com/dotnet/asynchronousdataaccess.asp?target=DAAB
This is another cool article.

HTH,

Bill
 
A Singleton can be a valid approach, especially if you want to go a step
further than the resources you list. I've created a persistence layer
which uses a singleton as the main access point into the framework, as
recommended by some prominent people in this field. My primary source of
inspiration were Martin Fowler and Scott Ambler (check out his excellent
paper at http://www.ambysoft.com/persistenceLayer.pdf).

My persistence framework is open source if you want to check it out. It
is available at http://workspaces.gotdotnet.com/gentle and there is a
introduction at http://www.mertner.com/projects/gentle.

Yours,
Morten
 
KMiller said:
Does anyone know if implementing a Singleton design pattern class to
be used as a data access component would make for a solid
architecture for an enterprise-wide .NET system?

I'm wondering if having a single point of entry won't become a
bottle-neck and reduce performance..

If anyone has any information pertaining to Singleton classes, I'd be
grateful.

No further comments about whether or not it's appropriate to *use* a
singleton, but I've got a page about the various implementation
patterns available here:

http://www.pobox.com/~skeet/csharp/singleton.html
 
Hi Morten:

Morten Mertner said:
A Singleton can be a valid approach, especially if you want to go a step
further than the resources you list. I've created a persistence layer
which uses a singleton as the main access point into the framework, as
recommended by some prominent people in this field. My primary source of
inspiration were Martin Fowler and Scott Ambler (check out his excellent
paper at http://www.ambysoft.com/persistenceLayer.pdf).

My persistence framework is open source if you want to check it out. It
is available at http://workspaces.gotdotnet.com/gentle and there is a
introduction at http://www.mertner.com/projects/gentle.

Yours,
Morten

Thanks for the info and I really enjoyed the read. I was thinking about it
in a different context but I can definitely see the benefits of your
implementation. I've seen a lot of posts about peopel wanting to use a
single connection in their app and approach it from that direction and
that's what I thought he was referring to but I think I misunderstood the
question.

BTW, your use of attributes in the implementation was very cool. Do you
have any other links that you'd recommend?

Thanks again,

Bill
 
Thanks, you're too kind :)

There are a bunch of other very interesting links on Ambler's site:
http://www.ambysoft.com/persistenceLayer.html

Fowler has written lots of good articles (and authored some excellent
books, all of them well worth their money).
http://www.martinfowler.com/articles.html

Patterns for Object/Relational Mapping and Access Layers:
http://www.objectarchitects.de/ObjectArchitects/orpatterns/

Object-Relational Mapping Articles:
http://www.service-architecture.com/object-relational-mapping/articles/index.html

Database Concepts and Standards:
http://www.service-architecture.com/database/articles/index.html

I found some interesting discussions here:
http://www.objectsbydesign.com/

That should keep you occupied for a week or so ;-)

Yours,
Morten
 
Back
Top