loading...

re: What Config Files Are & How They Work VIEW POST

FULL DISCUSSION
 

Yes I have done some advanced stuff with config filese, for example having a global and one or more local (user, group or department specific) configuration files. The application would search for the local files at different locations in a specific order. Depending on the type of configuration option, the local settings would either override the global ones or not.

Don't do this unless it is absolutely required. If you have any doubt, ask your customer if it is really needed. Complicated configuration rules can make testing, operations and support extremely difficult.

If you have to do it, add some verbose logging to your software that tells you exactly what value a setting has and where it comes fom, like:

Setting <x>=<y> read from local config <full-path-here>
    which overrides global config <full-path-here> with <x>=<y'>
    and default value <x>=<y''>

Another recommendation, for more or less the same reasons: Don't make everything configurable. Keep the number of settings small. There is nothing wrong with hardcoding some stuff as long as you define these constants at only one place in your code.

code of conduct - report abuse