Java Serialization

My recent experiments show that in the JavaLanguage, binary serialization works rather better than the rumors suggest even after changing and recompiling the source files, provided that we assign a serialVersionUID.

Just as one might expect.

A good rule of thumb is to assign a serialVersionUID any time we type implements Serializable.

I am now more excited about trying ThePrevayler or JavaSpaces


The consequences of relying upon serialization are still non-trivial, of course.

For the refactoring-addicts (which should be everyone), it means you need to think very carefully before doing an otherwise trivial activity like renaming a member variable.

Refactor -> Rename Variable -> Generate Migrator -> Yuck!

--Greg


Absolutely. Additionally, AnonymousInnerClasses present a new problem; if we intend to serialize them, we need to maintain the order in which they appear in the containing class. It is probably better to name any class which we intend to serialize.


I am still wary of using JavaSerialization when you need to make allowance for both upwards and downwards compatibility. Explicit serialization and deserialization seems a better approach - for the long term. OTOH all the data structures I consider serializing are relatively simple directed graphs.


CategoryJava


EditText of this page (last edited December 2, 2005) or FindPage with title or text search