In my current project I have a class like this:
CODE
[Serializable]
class SomeData {
...
}
[Serializable]
class ChildClass {
private SomeData data;
public SomeData Data {
get { ... } set { ... }
}
...
}
[Serializable]
class ParentClass {
private ChildClass MasterData;
private List<ChildClass> SwitchableData;
... (accessors and such-like etc.) ...
}
Currently, I took the easy way to store the stuff to disc by using serialisation. (Yes, I'm going to spell with British English). However, I know that in the future, the format of the data may possibly change (although that is rather unlikely to happen in the near to medium term).
If I do change the data structure inside any of the classes, then I need to have two sets of classes: the old one, and the new one. To load data made in the old one, just deserialise it with the old class, then have some (easy to write) code to transfer all the data to the new class.
However, that could eventually lead to (massive) code bloat.
The alternative is that I have both an XML reader and a writer, which would require me to write more code in the short term, but less code in the long term. Although in the long term.
So in other words, if I use serialisation, I can write minimal code now, but more extensive code later, and if I write XML (en/de)coders then I don't have to do much later to be able to open all versions of XML files.
The alternative would be to use a database, in which case code would be easy to write now, and in the future. If I used a database, it would be Firebird. Mainly because the application has to run on both Linux and Windows.
The database would also mean that the program doesn't have to spend time loading everything. I.e. it would only load data when it is accessed. If I use serialisation, everything gets loaded. Using XML I would have to load data only from one of the items in the "SwitchableData" list.
By the way, this is the basic layout for a language resource class. I don't like the way localisation works in Visual Studio so I'm rolling my own.
What do you guys/gals think?
At the moment I'm just using serialisation. But I'm currently leaning towards the database solution.