in reply to Configuration file design
Which is/would be a more typing for the user, and thus more to get wrong..
This isn't always a bad thing ... in fact, it's frequently a good thing.
By having a format with a little extra markup, you help reduce the number of missunderstandings about what was intended. In simple formats (like KEY=VAL) how does a person represent a value with a newline in it? or what about a key with an equals sign in it ... or a space?
The user might try these things, and your program might run just fine without any errors, because what they've given you is a valid file, it just may not be valid in the way they think it is. By having a few mandatory requirements that require a little additional typing, you can help ensure that there isn't any confusion.
Your INI file approach already does a little of this ... assuming you are validating that the only sections in the file are [main] and [ftpNN] where NN appears in the list of ftp_instances, and that everything in the list has a section -- that way you reduce the risk that they add an [ftp99] section without adding it to the list. But you should also worry about the possiblity of duplicate sections (happens a lot when people cut/paste key/val pairs and change the value but forget to change the key)
The biggest downside to an INI type solution is that it does require them to duplicate data ... you could avoid that by saying that the set of sections determines the number of FTP hosts, and eliminate the "ftp_instances" list completely -- but that's probably not very practical if you want to have lots of sections for lots of sets of config info.
Which is where XML style config files come in handy ... the biggest complaint against XML configs is duplicate markup; but nestability, quoting, and DTDs make it a really great choice to eliminate confusion and identify mistakes...
<config> <root>/path/to/root</root> <files>/path/to/files</files> <ftps> <instance id="00"> <source>/blah/path/blah</source> <save>/blah/path/blah</save> </instance> <instance id="01"> <source>/blah/path/blah</source> <save>/blah/path/blah</save> </instance> ... </ftps> </config>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Configuration file design
by Corion (Patriarch) on Jan 04, 2005 at 09:45 UTC | |
Re^2: Configuration file design
by castaway (Parson) on Jan 04, 2005 at 10:09 UTC |