Strong Coders Community

Where the extreme coders hang out.
Welcome to Strong Coders Community Sign in | Join | Help Messenger
in Search
Strong Coders Community » ASP.NET / .NET Framework » AspNet2 » Re: Is it advisable to implement Singleton pattern in ASP.NET

Is it advisable to implement Singleton pattern in ASP.NET

Last post 02-02-2007, 7:03 AM by JamesCurran . 1 replies.
Sort Posts: Previous Next
  •  02-02-2007, 2:34 AM 1703
    • manishbafna is not online. Last active: 02-09-2007, 3:26 AM manishbafna
    • Top 10 Contributor
      Male
    • Joined on 10-18-2006
    • India
    • Posts 48
    • Points 800

    Is it advisable to implement Singleton pattern in ASP.NET

    Hi,

    I have one query which if some experienced persons can give reliable answer to it.Is it advisable to implement singleton pattern in ASP.NET for having single database connection object throughout the application?Will website become scalable if we implement singleton pattern for single database connection in asp.net? or using(connection conn) syntax is better approach?

    I would be grateful if some experienced person can give reliable answer to it.

    Thanks and Regards,

    Manish Bafna.

    MCP and MCTS.

     

    • Post Points: 20
    • Alert the moderators
  •  02-02-2007, 7:03 AM 1705 in reply to 1703
    • JamesCurran is not online. Last active: Feb 11, 2007, 11:18 AM JamesCurran
    • Top 10 Contributor
      Male
    • Joined on 11-01-2006
    • Bloomfield, NJ, USA
    • Posts 82
    • Points 1,015
    • StrongCoders

    Re: Is it advisable to implement Singleton pattern in ASP.NET

    On the whole, I don't see the advantage.  First of all, ASP.Net programs are very short-lived.  They are started; they create one page, and then they die.  So, what you are talking about is not so much a singleton, but a persistant object.  There are many pros & cons with persistance.  However, with database connections, pooling is built in, so there not much advantage in doing it yourself.
    Truth,
    James
    • Post Points: 5
    • Alert the moderators

Powered by Community Server (Commercial Edition), by Telligent Systems