Inspired by RoR Migrations I’ll summarize how to gain similar benefits in the J2ME world with respect to it’s special needs:
- attach a version marker to each RecordStore name,
- as there’s no callback at install time and at launch time things must be quick as possible, use a fall-back mechanism on opening RecordStores,
- therefore use a custom method to open RecordStores and give it a handler for RecordStoreNotFoundException,
- use methods rather than classes to implement migrations,
- only migrate forward,
- hardcode the migration methods into the RecordStoreNotFoundException handler โ there’s no Reflection in J2ME.
=>
- you can change the RMS store names and storage byte semantics whenever you like without the fear of breaking anything,
- there’s impact on startup time only if the storage semantics changed and needs to be converted,
- you don’t add myriads of classes over time,
- you need to write a converter method for each version bump of each store.
Check back later for sample code.