Where exactly the Singleton Pattern is used in real application?

前端 未结 12 518
囚心锁ツ
囚心锁ツ 2021-01-30 06:35

I was just curious where exactly the singleton pattern is used... I know how the pattern works and where it can be used but i personally never used in any real application. Can

12条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 07:26

    Singleton Pattern can be used for loading the configuration , say in a web application, we are supposed to generate a file which is to be stored somewhere in the server. Now, that location can fetched from a config file(properties file) using a singleton class.since the location is to be unique and might change frequently in future, so we use a config file so as can be modified without deploying the application so as to reflect the changes and location will be global and unique through out the application

提交回复
热议问题