Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application configuration files [closed]

OK, so I don't want to start a holy-war here, but we're in the process of trying to consolidate the way we handle our application configuration files and we're struggling to make a decision on the best approach to take. At the moment, every application we distribute is using it's own ad-hoc configuration files, whether it's property files (ini style), XML or JSON (internal use only at the moment!).

Most of our code is Java at the moment, so we've been looking at Apache Commons Config, but we've found it to be quite verbose. We've also looked at XMLBeans, but it seems like a lot of faffing around. I also feel as though I'm being pushed towards XML as a format, but my clients and colleagues are apprehensive about trying something else. I can understand it from the client's perspective, everybody's heard of XML, but at the end of the day, shouldn't be using the right tool for the job?

What formats and libraries are people using in production systems these days, is anyone else trying to avoid the angle bracket tax?

Edit: really needs to be a cross platform solution: Linux, Windows, Solaris etc. and the choice of library used to interface with configuration files is just as important as the choice of format.

like image 697
ninesided Avatar asked Aug 15 '08 11:08

ninesided


People also ask

What is application configuration file?

An application configuration file is an XML file used to control assembly binding. It can redirect an application from using one version of a side-by-side assembly to another version of the same assembly. This is called per-application configuration.

Where are app config files stored?

The application configuration file usually lives in the same directory as your application. For web applications, it is named Web. config. For non-web applications, it starts life with the name of App.

How do I open Visual Studio app config?

In Solution Explorer, right-click the project node, and then select Add > New Item. The Add New Item dialog box appears. Expand Installed > Visual C# Items. In the middle pane, select the Application Configuration File template.


2 Answers

YAML, for the simple reason that it makes for very readable configuration files compared to XML.

XML:

<user id="babooey" on="cpu1">     <firstname>Bob</firstname>     <lastname>Abooey</lastname>     <department>adv</department>     <cell>555-1212</cell>     <address password="xxxx">[email protected]</address>     <address password="xxxx">[email protected]</address> </user> 

YAML:

    babooey:         computer : cpu1         firstname: Bob         lastname: Abooey         cell: 555-1212         addresses:             - address: [email protected]               password: xxxx             - address: [email protected]               password: xxxx 

The examples were taken from this page: http://www.kuro5hin.org/story/2004/10/29/14225/062

like image 68
engtech Avatar answered Sep 23 '22 00:09

engtech


First: This is a really big debate issue, not a quick Q+A.

My favourite right now is to simply include Lua, because

  • I can permit things like width=height*(1+1/3)
  • I can make custom functions available
  • I can forbid anything else. (impossible in, for instance, Python (including pickles.))
  • I'll probably want a scripting language somewhere else in the project anyway.

Another option, if there's a lot of data is to use sqlite3, because they're right to claim

  • Small.
  • Fast.
  • Reliable.

Choose any three.

To which I would like to add:

  • backups are a snap. (just copy the db file.)
  • easier to switch to another db, ODBC, whatever. (than it is from fugly-file)

But again, this is a bigger issue. A "big" answer to this probably involves some kind of feature matrix or list of situations like:

Amount of data, or short runtime

  • For large amounts of data, you might want efficient storage, like a db.
  • For short runs (often), you might want something that you don't need to do a lot of parsing for, consider something that can be mmap:ed in directly.

What does the configuration relate to?

  • Host:
    • I like YAML in /etc. Is that reimplemented in windows?
  • User:
    • Do you permit users to edit config with text editor?
    • Should it be centrally manageable? Registry / gconf / remote db?
    • May the user have several different profiles?
  • Project:
    • File(s) in project directory? (Version control usually follows this model...)

Complexity

  • Are there only a few flat values? Consider YAML.
  • Is the data nested, or dependent in some way? (This is where it gets interesting.)
  • Might it be a desirable feature to permit some form of scripting?
  • Templates can be viewed as a kind of configuration files..
like image 30
Anders Eurenius Avatar answered Sep 21 '22 00:09

Anders Eurenius