.Net Framework, Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML

Ado.netAsp.Net 2.0SQLC-SharpXMLFrameworkIISXMLWebServiceArchitecture
UMLProject ManagementSDLCMethodologiesDesign PatterenOOPWCF.Net RemotingWWF
MVPMVCSilver LightN-HibernateAjaxJ-QuerySEO-MarketingSite MapPhp

Singleton design pattern

Sometimes when developing big application we come across situation when the instance of a class has to be instantiated only once.
In this scenario the design pattern we follow is named as singleton pattern. Implementing singleton pattern ensures that a class will have only one instance created and also provides a global point of access to class instance.
Singleton Design Pattern
namespace Arindam
1:{
2: public class ETGSingleton
3: {
4: private static ETGSingleton _instance;
5: private int counter =0;
6: private ETGSingleton()
7: {
8: //
9: // TODO: Add constructor logic here
10: //
11:
12:
13: }
14:
15: public static ETGSingleton Instance
16: {
17: get
18: {
19: if (_instance == null)
20: _instance = new ETGSingleton();
21: return _instance;
22: }
23: }
24: public int getCounter()
25: {
26: return counter++;
27: }
28: }
29:}
30:
Singleton design patternsProxy design patternsFactory Abstract factory design patterns
MVP design patternsMVC design patternsSOA
Leave your comment.
Name
Email
Comments
Tell Us7395+5 =

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

Privacy Policy ©2009 ETG Consultancy, All Rights Reserved Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML