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>

In reply to Re: Configuration file design by hossman
in thread Configuration file design by castaway

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.