Most of my programming was in web applications, although I developed some desktop applications for personal projects. A recurring design problem was how to manage the configuration. For example, we all know that in ASP.NET web.config is often used to store configuration information, regardless of whether it is created or configured manually.
Before I even realized what the design patterns were, I would have done what would essentially be a Singleton pattern. I would write a static class that at startup would read the configuration file and save the information along with any automatically generated information in the fields, which were then exposed to the rest of the application through some kind of access element (properties, get () ...).
Something deep in my mind keeps telling me that this is not the best way to handle this. So my question is: are there any design patterns or recommendations for developing a configuration system? When and how should the configuration system read the configuration and how should it disclose this information to the rest of the application? Must it be Singleton? I do not ask about recommended storage mechanisms (XML vs database vs text file ...), although I am also interested in the answer.
source
share