[jdom-interest] TODO serialization [eg]

Joseph Bowbeer jozart at csi.com
Sat Apr 14 04:21:43 PDT 2001


There is a "serialization" item in the TODO list already.  This information
supplements that item.

0. Do we really want to make the JDOM classes Serializable?  It's a lot of
work to do this right and then to maintain it (see below).  Just checking...

1. serialVersionUID.  We should add explicit serialVersionUID definitions.

2. Custom serialized form.  We should create a custom serialized form rather
than using the default serialized form.  The default serialized form is
generally a bad choice (except for simple "data" classes) because it allows
the implementation details to leak-out into the public.  Therefore it's
usually best to declare every field transient and code your own custom
serialized form.  In addition to hiding implementation details, a custom
serialized form can be more efficient in both space and time.

3. Document @serial and @serialData.  Every non-transient field should
include a @serial javadoc comment.  This applies to private fields as well.
(Effective Java says: "That is because these private fields define a public
API, the serialized form, and this public API must be documented."

Similarly, the writeObject method should include a @serialData comment
describing the serialized form.

4. Overridable.  As was mentioned in the message about subclassing,
readObject should not invoke any overridable methods.

--
Joe Bowbeer









More information about the jdom-interest mailing list