Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Mark Brackett
OM > Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connection > challange > > Thanks for this excellent responses. I agree with Ben that code > consistency > is important and I am trying to enforce it in my team. Well, the reason > I > posted this code is to see the

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Shane Courtrille
[EMAIL PROTECTED]> wrote: > > > > Many thanks for the clarification, gentelmen. > > > > > > > > On 10/17/07, Richard Blewett <[EMAIL PROTECTED]> wrote: > > > > > Dispose also returns the connection to the connection pool > > > > >

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Sébastien Lorion
; > > > > > > > Regards > > > > > > > > Richard Blewett - DevelopMentor > > > > > > > > > -Original Message- > > > > > From: Discussion of advanced .NET topics. [mailto:ADVANCED- > > > > > [EMAIL PROTECTE

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Ryan Heath
> Regarding ASP.NET, I'm of the school of thought that database > connections be created at function level; as in, created and destroyed > many many times (if necessary) throughout the page life-cycle. > We do keep the connection "alive" during the page request. We were seeing too many calls to th

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Ryan Heath
> I personally think that grading the code as A or D is not a good idea. We are > not > evaluating a person / dev but the code. Huh, but the *code* is evaluated, not the person who wrote it... // Ryan === This list is hosted by DevelopMentor® http://www.develop.

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Abhijit Gadkari
pics. [mailto:ADVANCED- > > > > [EMAIL PROTECTED] On Behalf Of Smotritsky, Alex > > > > Sent: 16 October 2007 22:01 > > > > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > > > > Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connection > > > > cha

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Baris Acar
connection from the connection pool on open and return it on > > > close so you get connection pooling for free. > > > > > > -Original Message- > > > From: Discussion of advanced .NET topics. > > > [mailto:[EMAIL PROTECTED] On Behalf Of

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-17 Thread Ben Joyce
: Discussion of advanced .NET topics. [mailto:ADVANCED- > > [EMAIL PROTECTED] On Behalf Of Smotritsky, Alex > > Sent: 16 October 2007 22:01 > > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > > Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connection > > challange > > &g

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Richard Blewett
ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connection > challange > > The open and close methods of the connection object in ado.net usually > take the connection from the connection pool on open and return it on > close so yo

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Sébastien Lorion
> > -Original Message- > From: Discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of Mike Andrews > Sent: Tuesday, October 16, 2007 2:34 PM > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connectio

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Smotritsky, Alex
Mike Andrews Sent: Tuesday, October 16, 2007 2:34 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Singleton and Database Connection challange This is not the place for a singleton and the singleton is not implemented correctly since it doesn't take into account any

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Curt Hagenlocher
On 10/16/07, Ben Joyce <[EMAIL PROTECTED]> wrote: > > Regarding ASP.NET, I'm of the school of thought that database > connections be created at function level; as in, created and destroyed > many many times (if necessary) throughout the page life-cycle. > > Just out of interest, is there *any* situ

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Ben Joyce
Regarding ASP.NET, I'm of the school of thought that database connections be created at function level; as in, created and destroyed many many times (if necessary) throughout the page life-cycle. Just out of interest, is there *any* situation of school of thought where a single application-level c

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Mike Andrews
This is not the place for a singleton and the singleton is not implemented correctly since it doesn't take into account any race conditions that might occur with a multi-threaded app such as asp.net. Also you would not want to dispose of the connection in the singleton since that defeats the purpo

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Greg Young
Also whats the point of setting d = null in page unload? On 10/16/07, Greg Young <[EMAIL PROTECTED]> wrote: > I would give this a C- or D as well ... not because the Singleton is > implemented incorrectly but because it shouldn't be a singleton in the > first place. > > 1) whats the point of being

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Shane Courtrille
I'm more of a WinForms developer but I would think that a singleton for your database connection in a Web Application would be a bad idea my understanding is that by default IIS will service 10 threads at a time so now you have 10 threads fighting over that database connection.. assuming it's e

Re: [ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Greg Young
I would give this a C- or D as well ... not because the Singleton is implemented incorrectly but because it shouldn't be a singleton in the first place. 1) whats the point of being Disposable? You are a singleton ... if anyone disposes you you trash your internal state and start returning a dispos

[ADVANCED-DOTNET] Singleton and Database Connection challange

2007-10-16 Thread Abhijit Gadkari
We are writing an ASP.NET application. We have used singleton for instantiating a database connection as explained in the following code sample. Design thought was to use only one instance of MyDb across all the pages in this web application. Is this a correct singleton implementation for Asp.NE