09-18-2011 11:14 PM
Hello all,
I am planning on upgrading an application but it seems I forgot about the possibility of the structure of my class changing in the future by adding other objects to it.
Is the best practice to just have place holders in a class?
e.g.
public class Settings implements Persistable{
int placeholder1;
int placeholder2;
int placeholder3;
...
}
How should I handle the change to the format in an upgrade, create a mirror of my old class, read it in the updated app, then save it in the new structure and save that?
Solved! Go to Solution.
09-19-2011 04:01 AM
09-19-2011 07:13 PM
09-19-2011 09:45 PM - edited 09-20-2011 05:19 AM
It is certainly the way I recommend. I particularly like Hashtable.
09-19-2011 09:47 PM
09-20-2011 04:18 AM
Yes... One good thing that you can do...
Use IntHashtable Instead of Hashtable and define all int keys whatever you want to put on that and put the value on IntHashTable.
09-20-2011 11:42 AM
09-20-2011 12:32 PM
Using IntHashtable It is very simple process and it will handle all the scenario.
Make a Class which will have all getter and setter of your specific.
Define your public static final int keys to mape your data.
Keep a object of intHashtable and initialy read it from Persistance if it is there then then assign else creat new and commit.
Now in your getter and setter read the object from IntHashtable for that specified key if its not there then return the default value and in each setter put the value on the key in IntHashtable and commit it.
Done ![]()