Resources for creating a good, extensible file format
September 4, 2009 10:35 PM
Subscribe
My team and I are writing a computer application for which aspects of the file format are very likely to change in future releases. The format is in XML. Does anyone know any resources on the web that lays down general principles about how to make a file format that is as extensible as possible for the future (and minimizes the possibility of cross-version breakage)?
posted by SilentSalamander to computers & internet (7 comments total)
9 users marked this as a favorite
1) Include a filespec version number in the file itself. Don't try to do this based on magic numbers or format analysis or whatever. Just add a <formatversion>1.0</formatversion> element. Or, add a version attribute to the document element.
2) Write a conversion tool or module.
So, you have a v1.0 file spec. You write a module to read/write it, and you name it FileServicesV1. Then, for your v2.0 release, you do not change the FileServicesV1 module, but rather add a FileServicesV2 module. Then, when you encounter a v1.0 file, you pull it in with FileServicesV1 into your internal representation. When it comes time to save it, output it with your FileServicesV2 module.
You can also make this an external tool, or a Save As... with a "some formatting will not be saved" kind of message, if you want to give your users the option.
posted by Netzapper at 10:57 PM on September 4