[plt-scheme] Upwards and Downwards Compatible Object Serialization
I'm using serializable objects defined by the new
define-serializable-class. Works great! But ultimately, my classes will
have to implement externalizable<%> in order to support either SXML or
XML as a generic data format.
Now I can't figure out how to make such data upwards and downwards
compatible. By this I mean the following. My application v1.0 starts
with using class A and externalizes it. Then application v1.1 defines a
subclass B of A, which adds a lot of fancy additional fields to A, but
inherits everything else from A. I want application v1.0 be able to
read any externalized instance of B as if it was data of class A,
simply skipping any additional v1.1 stuff. Likewise, v1.1 has to be
able to read externalized objects of class A as instances of class B,
where the additional fields are given their default value. And so on
for all other versions.
Any solution I've come up with so far seems to be clumsy and error
prone to me. Perhaps "I can't see the wood because of all the trees" as
a German proverb says. I'm looking for advice and ideas how to
implement this functionality. Any suggestions?
Best regards,
Erich