Alex Rivera | Logout

Singleton for Application Configuration

Asked 2008-12-17T04:06:33.683
33

In all my projects till now, I use to use singleton pattern to access Application configuration throughout the application. Lately I see lot of articles taking about not to use singleton pattern , because this pattern does not promote of testability also it hides the Component dependency. My question is what is the best way to store Application configuration, which is easily accessible throughout the application without passing the configuration object all over the application ?.

Thanks in Advance

Madhu

Edit
Report

2 Answers

1

For that specific situation I would create one configuration object and pass it around to those who need it.

Since it is the configuration it should be used only in certain parts of the app and not necessarily should be Omnipresent.

However if you haven't had problems using them, and don't want to test it that hard, you should keep going as you did until today.

Read the discussion about why are they considered harmful. I think most of the problems come when a lot of resources are being held by the singleton.

For the app configuration I think it would be safe to keep it like it is.

answered 2008-12-17T04:19:41.927
-1
answered 2011-03-04T19:43:29.030

Your Answer