On 5/27/20 8:51 AM, Jialin Qiao wrote:
Hi,

Providing a Serializable interface looks more uniform.
However, if more and more classes implement this interface, it may be hard for 
developers to find usage of a specific class, such as PageHeader.serialize or 
ChunkHeader.serialize.  This may be a problem...

This is interesting point, that triggered me my curiosity, instead of depending on hierarchy we could get rid of serialization code from classes. The final result could be:

 *try (var stream = new FileOutputStream("pageheader.dat"))*  {
       var serializer = new PageHeaderSerializer();
       serializer.serializeTo(stream);
 }

All serializer objects will implement serializeTo and deserializeTo, so in this 
case we can enforce the separation of concern. The data/model header is just a 
stupid bean without any logic, where each serializer implements
the DataSerializerInterface.

Best Regards,
Giorgio.

Reply via email to