design - Representing parameters/configurations/settings -
OK, we say that I am writing an application using an object-oriented language, and I have Key-pairs pairs that represent program parameters / configurations / options / settings / etc. These may be the initial value of some variables, or only those values which are not obliged to change the addition of sessions In my data model these I value the price I can represent?
My initial idea is to store all the values in only one class that can be reached globally (possibly singleton) because these values will be used in different places of the code. However, it will depend on this singleton to the other singles.
Is there a problem in this situation? Is there another ideal solution I have not thought of? How do you usually represent this kind of data? Should I be aware of anything related to this problem?
Thanks
You would like to use dependency injection An interface IConfigurationProvider Create . Create a class DefaultConfigurationProvider , which implements the interface and performs the actual function. Creates another object that relies on config data, expects an IConfigurationProvider example and provides an example of DefaultConfigurationProvider . The most dependent injection framework will handle it for you.
Comments
Post a Comment