What is a good design for allowing backwards compatibility of a file type between different versions of software?
For instance, how does microsoft get word 2007, 2010 and 2013 etc... to all open docx files, but different editions can save more / less data and save the data in slightly different ways, all to the same file type, and a file that is saved in one version can be opened in another, but certain elements of the file might not be available in older versions?
I mean, the really obvious way to do it is to have something like
private string openfile(string filename)
... some logic that gets a header from the file that will never change
but that seems incredibly monolithic, not very extensible, and likely to lead to a lot of copy / pasted code.
So I was thinking of using a base interface for all versions which defines the immutable structures, such as the header, that need to be present in the file, and methods that need to be available for serialisation / deserialisation, then multiple inheritance so that each new version's class that implements the interface inherits the old version, and only overrides stuff that has changed, since the file will be the same, for the most part.
I'm not really bothered about the structure of the file, since it's already decided that we'll be using XML, and the initial schema is, by and large, already decided. However there will no doubt be changes to it in the future, and I just want to be able to design the code in a way that makes it easy to accommodate these changes.