开发者

Sane Configuration Method for very Complex Piece of Software?

开发者 https://www.devze.com 2023-02-12 05:08 出处:网络
We are writing a C++ program, that needs to be highly configurable (at start time). Right now we have a base XML file, which contains several configuration variables, and filenames of other XML files开

We are writing a C++ program, that needs to be highly configurable (at start time). Right now we have a base XML file, which contains several configuration variables, and filenames of other XML files开发者_如何学Python with more configuration variables. All in all, we have a tree of about 10 XML files, and several binaries file formats with some other content.

We are now at a point where it is getting extremely messy: Since the files are interlinked, it is difficult to find which files are actually parsed and which configuration needs to be edited or which paths to be set.

Are there any better ways to implement a configuration for a complex piece of software except interlinked XML files?

One advantage of this approach that I'd hate to loose, is that it is relatively easy to switch from one part of the configuration to another. For example we have two configuration files for two different Robots, and to switch between which robot we are using we simply link the correct file from the base XML file.

EDIT Some possible ideas might be:

  • Switch to using a database? This would be highly configurable but is not as human-readable.
  • Some structure like firefox's about:config?
  • One huge flat .ini file and just deal with copying stuff around? not an option, this would be even more cumbersome
  • ...


Lua was designed for configuration.


If you are using C++ you can use

http://www.boost.org/doc/libs/1_45_0/doc/html/program_options.html Boost Program Options.

It allows you to store configs in files and use command line args interchangeably.


I mostly come from Java and .NET world but can totally understand the pain it involves to have so many configuration files, different envrionments and shared configuration parameters. As one solution for a previous company we started building something which helped us a lot by allowing configuration inheritence, templating and strongly types configuration values as well as auditing and access control for configuration.

We are releasing our solution as a hosted configuration management service soon. If you are interested, signup for a beta at http://woot.configchief.com

0

精彩评论

暂无评论...
验证码 换一张
取 消