Alternatives to the Singleton Design Pattern
page 1 of 6
Published: 23 Nov 2010
Unedited - Community Contributed
The Singleton Design Pattern is one of the simplest and most widely known design patterns in use in software development. However, despite its simplicity, it is very easy to get wrong and the consequences of its use even when properly implemented can outweigh its benefits. It turns out there are other ways to achieve the goals of the Singleton pattern which will often prove to be simpler, safer, and more maintainable.
by Steven Smith
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 29115/ 60


The Singleton Design Pattern is one of the simplest design patterns in software development, yet one of the easiest to misuse as well.  In this article, we'll examine some alternatives to the Singleton pattern in its most naïve implementation, as well as consider an alternative to making classes themselves responsible for managing their instances.

View Entire Article

User Comments

Title: Just use public static readonly   
Name: Ramon Smits
Date: 2010-12-08 7:42:43 PM
Just use a public static readonly member. Easy, fast, lazy and threadsafe!

public class MyClass
public static readonly MyClass Instance = new MyClass();
private MyClass(){}

Much easier then this will be difficult to do!

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-24 9:37:45 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search