Design Patterns
Singleton Design Pattern Some types have not any reason to instantiate more then once in a project. For example creating a database connection every time take some costs or creation of logger in a project also consume memory of object creation each time. To avoid this we need to make a type as singleton by doing this we can instantiate it only one time and use it anywhere throughout the application or module. Sometimes we have a task to read some data from file, so we can create a single instance of object that read data from file and share it through the project to consumers. Let's start with creating a singleton class. To achieve this we have created an interface that contains one method of SingletonContainer class. public interface ISingletonContainer { int GetPopulation(string name); } we will create a class that read the population data from file in a constructor and returns pop