The simplest thing for you is to use serialization, IMO, but get more into the serialized form of classes (which you really should do anyway). For example:
- Explicitly determine SerialUID.
- Define your own serialized form, if necessary.
The serialized form is part of the API class, and careful thinking should be included in its design.
I will not go into details because almost everything I said comes from Effective Java. Instead, I will tell you about this, namely the chapters on serialization. He warns you about all the problems that you have encountered, and offers the correct solutions to the problem:
http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683
With that said, if you are still considering a non-serialization approach, here are a couple:
XML sorting
As many have pointed out, this is an option, but I think that you will still encounter the same backward compatibility issues. However, with XML sorting, you are likely to understand them right away, as some frameworks may perform some checks for you during initialization.
Convert to / from YAML
This is an idea I played with, but I really liked the YAML format (at least as the custom toString () format). But in fact, the only difference for you is that you have to sort YAML instead of XML. The only advantage is that YAML is a bit more readable than XML. The same restrictions apply.
Jack Leow Oct 27 '08 at 12:23 2008-10-27 12:23
source share