Is anybody aware of any design patterns around software updates? Specifically I'd like a pattern for converting old files/settings into the latest version.
The best solution I can think of would be to have a set of rules for how to convert from each version to the next version (e.g. v1.0 to v1.1, v1.1 to v1.2, ...). Then to convert files/settings to the latest version you would run all the conversion rules in order.
This doesn't strike me as a very elegant way of doing things - is there a better way?
I worked in a system which included a versioning system to migrate a DB to the latest version, and it worked like that. The only improvement we did, is that we sometimes wanted to avoid going through all versions, since it was a lengthly process, so you could define migrations from any version to any version if you are in version 1.3 and want to migrate to the latest version and you have scripts to migrate from:
I'd detect automatically that it can use a single script to go over three versions 1.4 to 1.7 and use 1, 6 and 5. That's only worth it if the migration is lengthy though...
If you don't need to actually migrate the data, but just use it in the format of the latest version, you could achieve the same using the Adapter Pattern using object composition to transform an object with the "1.3" format to the "1.8" format using a chain of adapters in the middle.
In response to comment: Sadly, we had to do the 1.4 to 1.7 by hand. You'll need something pretty smart to be able to compose optimized updates scripts from the individual ones, without executing them sequentially.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With