I am attempting to set up a reliable method of updating my software in the future by assuring I can smoothly update my user's files whenever I release a program update. The software is written in C#.
Say I have a person object:
- Name
- DoB
- Nationality
So that's version 0.1 of my person class. In the future, for the sake of example, I introduce some new fields to the person object (v0.2).
- Name
- DoB
- Nationality
- Temperament <- NEW
- Job <- NEW
Obviously I need to update the old object to the new one. What I am currently doing is the following:
- Read the 0.1 object into a versioned class (like Person01.cs).
- Populate the new object with the fields that the old object had.
- Populate the new fields of the new object with default values.
- Write out the file.
This seems tremendously inefficient. It requires a great deal of custom coding every time I make any change. There must be a better way to do this, but as this is my first time really working with XML I'm not sure how to go about it. Any help you can provide would be greatly appreciated. I have searched for a solution to this problem but I am only finding unrelated results.