I have been mulling over config files and their relationship to code for a while now and depending on the day and direction of the wind my opinions seem to change. More and more though I keep coming back to the realization I first had while learning Lisp: there is little difference between data and code. This seems doubly true for config files. When looked at in the right light a Perl script is little more than a config file for perl. This tends to have fairly heavy consequences for tasks such as QA and divisions of labor like who should be responsible for changing config files.
The creep from config file to full fledged language is generally slow and seems to be driven by the desire to have a generic system. Most projects seem to start out small with a few config items like where to write logs, where to look for data, user names and passwords, etc. But then they start to grow: features start to be able to be turned on or off, the timings and order of operations start to be controlled, and, inevitably, someone wants to start adding logic to it (e.g. use 10 if the machine is X and 15 if the machine is Y). At a certain point the config file becomes a domain specific language, and a poorly written one at that.
Now that I have rambled on to set the stage, here are my questions:
- What is the true purpose of a config file?
- Should an attempt be made to keep config files simple?
- Who should be responsible for making changes to them (developers, users, admins, etc.)?
- Should they be source controlled (see question 3)?
As I said earlier my answers to these questions shift constantly, but right now I am thinking:
- to allow a non-programmers to change large chunks of behaviour quickly
- yes, anything that is not coarsely grained should be in code
- users should be responsible for config files and programmers should be responsible for a configuration layer between config files and code that gives more fine grained control of the application
- no, but the finer grained middle layer should be