Configuration Files

Configuration files are increasingly being used to control the behaviour of application programs. For a small program with a well defined behaviour, command line parameters can be used to alter the behaviour of a program without having to modify and recompile its source code. However, larger and more complex applications, like most of the existing business-critical web applications, carry out a large number of broadly varying tasks. These applications have lots of potential configurations and behaviours. Designers have resorted to using configuration files that are read during initialisation time or monitored during run-time to alter the application's behaviour.


Now, the drawbacks of this approach are as follows.

There are some ways to dodge these problems:


Some will also suggest ExtensibleMarkupLanguage (XML) or various other options like YamlAintMarkupLanguage (YAML). I guess they've somehow made these succeed without feeling disgusted with the resulting product. Here are my feelings on these subjects:

If you need 'declarative' ConfigurationFiles (e.g. for GatedCommunityPattern), I happily suggest you start with DataLog. Alternatively, have the initial configuration build the declarative configuration as a large value or set of tables. It's what you'd have had to do with XML or YAML streaming anyway. Seriously, the abstraction that comes from a real ScriptingLanguage will greatly help you avoid ConfigurationManagement issues from exploding, and will allow a great deal of reuse. YouAreGonnaNeedIt.


As always GreenspunsTenthRuleOfProgramming applies: EmacsLisp.


In the course of developing a simulation app in Java the required many numeric configuration parameters, I developed the OverridableCodeConstants patterns, which I backed with an XML file accessed through the http://jakarta.apache.org/commons/configuration implementation, which provides a means to EasyFindMutableConfigFilesInJava.

-- BenHutchison?


What we need is a simple solution that would enable us to dynamically control and configure the behaviour of complex applications. The solution needs to be more reliable and less cumbersome than configuration files and should lead to a much smaller code base.

-- AmitShanbhag


After being repeatedly repulsed by ApacheTomcat configuration files I have moderated my praise for XML config files (though the encoding really doesn't matter) somewhat. If the config files are simple then it can work. But the Tomcat config files are anything but simple. There are billions of options and locations and poor documentation. I desperately need a GUI to help with the configuration. A GUI should encode all the things I need to do and could do, but don't know about. For example, how the hell do I turn on debugging so I can trace servlet requests? What magic context needs to be placated?

As you say, this has not much to do with ExtensibleMarkupLanguage; a ConfigFileFromHell? will be such no matter what format it's rendered in.

Putting Tomcat -- or any other app, for that matter -- config files in XML would at least make it easy to create XSLT translations and Schema to make sure the config isn't hosed from the get-go. Also, XML can be edited directly using a slew of available editors. Hmm. I might attack my Apache and Tomcat configs to move them into XML...

Editing is fine. Knowing what options are available isn't.

When I saw this entry, my first thought was "Tomcat config files". And regardless if it is easy to edit XML files with any editor - a configuration program definitely is a must taking the 1000001 options of Tomcat into account. Having a configuration program which includes all options however, makes the file format, in which configurations are saved, unimportant. Although XML still has the advantage then, that you can edit it with any editor and don't NEED the configuration program.

Well I am glad I have never had to configure Tomcat, but I still agree that XML config files can suck. Why are people so hung up on XML? Most config files have a few uniquely named properties that can be assigned values - nothing more. so why insist on firing up an XML parser for that? Simple properties files can even be accumulated into one if a bit of care is taken when defining namespaces. That is often impossible in XML.

As was pointed out XML isn't really the problem. I think XML is as good as any format. The problem is if it's not something you know intimately, complex configuration files for a complex product are virtually unusable. So regardless of the encoding a GUI needs to be available to encode the knowledge of what can be done.

But once you have a GUI to edit the config file, why bother with XML? A less verbose format can do everything XML can do if you remove the requirement that humans will read and edit it by hand.

Though I prefer property files to XML, the real problem isn't that XML config files can suck; instead it's that badly-designed configuration mechanisms suck. A poorly designed GUI can be just as unusable as an obstruse XML file.

The best approach is to design the configuration mechanism, whether it's a file or a GUI, to be as intuitive as possible to the person configuring the system. You can always write code that converts the configuraton into whatever internal format is most convenient.


EditText of this page (last edited June 17, 2009) or FindPage with title or text search