Community discussion forum

ASP.NET Patterns every developer should know

This is a comment thread discussing ASP.NET Patterns every developer should know
  • 11 months ago
    As I am foreign to ASP.NET, I enjoyed general section a lot. You are good speaker, possibly sometimes there was to much words used where it could be easily shorten. But generally pretty interesting reading, and of course educative. I also like you included singleton, while it complements thema importantly, so that it is visible where it all also starts or just can begin :)
  • 11 months ago
    DO NOT USE THIS SINGLETON EXAMPLE CODE! It is not threadsafe! I've made this mistake before, and I've seen a lot of examples of Singleton done this way, but it is not threadsafe, which will cause you problems when using it in multi-threaded applications (like ASP.Net). The best code examples of ways to implement a Singleton in .Net can be found on Jon Skeet's site, [http://www.yoda.arachsys.com/csharp/singleton.html](http://www.yoda.arachsys.com/csharp/singleton.html). There are 5 examples of Singleon there, 3 NOT to use (including the version listed here) and 2 to use. And the best thing about the valid examples, no locks! Don Demsak www.donxml.com
  • 11 months ago
    Thanks for that. Very good link. Andy Grant
    Post was edited on 19/11/2008 11:00:42 Report abuse
  • 11 months ago
    Thanks. Very interesting idea. I like "full lazy" implementation of thread safe singleton

    internal static readonly Singleton instance = new Singleton();
  • 11 months ago
    We have added a note in the article from the Alex Homer on the implementation of Singleton pattern to clarify the issues raised! (see below, and inline in the article) > Note that this implementation does not perform locking while it creates the instance. > In reality, in this specific scenario, if a second thread should create a second instance it will > not affect operation because the content is read-only and is the same for all instances. If you absolutely > need to confirm that only one instance can ever exist, you should apply locks while checking for > and creating the instance. For more details, see [Implementing the Singleton Pattern in C#](/article/9407/) and > [Data & Object Factory Singleton Pattern](http://www.dofactory.com/Patterns/PatternSingleton.aspx)
  • 7 months ago
    Thanks! This is a great read.
  • 4 months ago

    The new VSTS enables you to convert your imagination into the perfect material images on screen ! Let your mind do the thinking and VSTS will do the rest .................................http://bit.ly/izsu9

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback