Skip to main content

Posts

Showing posts from April, 2014

Singleton Design Pattern in C#

The singleton pattern is one of the best-known patterns in software engineering. In singleton pattern we ensure that the class has only one instance and we provide a simple and global point of access to this object. This is useful when we require exactly one object of a class to perform our operations. Singleton classes don’t allow any parameters to be specified when creating the instance because a second request for an instance but with a different parameter could be problematic.
In this post I’ll provide you a real time example, Comparison of Singleton with Static class, UML class diagram of Singleton and then implementation of Singleton in various ways.
Example: The practical implementation of Singleton design pattern can be seen in various applications used by us. Take the example of Microsoft word, there is only one instance of the word application active at a time even though user opened multiple documents at a time. And all the requests for different word documents are handled by …