I’m currently quite curious in how other programmers organise data into files. Can anyone recommend any good articles or books on best practices for creating file structures?
For example, if you’ve created your own piece of software for whatever purpose, do you leave the saved data as plain text, serialize it, encode to xml, and why do you do this?
Are there any secrets I’ve missed?
Generally, go with the simplest thing that can possibly work, at least at first. Consider, eg, UNIX, where most of the configuration files are nothing but whitepace-delimited fields, or fields delimited with another character (like /etc/passwd, which uses ‘:’ delimiters because the GCOS field can contain blanks.)
If your data needs a lot more structure, then ask yourself ‘what tools can I use easily?’ Python and Ruby have JSON and YAML, for example.
XML is basically useful if you have lots of XML-based stuff already, OR you expect to transform the XML to a displayable form in a browser. Otherwise, it’s usually very heavyweight (code size, complexity) for what you get from it.