I was curious to know if anyone has suggestions about maintaining various
versions of class definitions when using serialization to save data.
Is there a "standard" way of handling backward compatibility with previous
version file structures? I don't have problems within the program itself,
just with loading data from files created with previous versions of the
class definition. It seems that if a change as minor as changing a property
name, even if the value type and behavior remain the same, it's no longer
compatible with files created using the previous structure.
Here's what my original plan was:
1. Incorporate the version information into the file names (In this program
all files are managed automatically through the program and the user really
never uses the file name)
2. Create a new class definition each time I need to modify the class,
leaving the previous versions of the class definition in tact. The new
definition would have a modified class name to reflect the version.
3. Use the appropriate class definition when reading in the data and perform
any conversions required at that time.
4. Save the file using the latest class definition and modify it's name to
reflect the change.
This seems like a lot accounting of work, am I missing something obvious?
I'll end up with quite a few versions of the class definition used in this
program to store the data. Is it unusual to use serialization to save and
retrieve data this way? Unfortunately it's very difficult right now to nail
down the final class structure as request for new capabilities are handled
and incorporated into the program.
Any comments and/or suggestions are greatly appreciated.
Thanks,
Dave