On Tuesday, 6 October 2015 at 10:05:46 UTC, Alex wrote:
I wonder if it would be better to write a more abstract serialisation/persistance module that could use either json,xml,some binary format and future formats.

I think there are too many particulars making an abstract (de)serialization module unworkable.

If that wasn't the case it would be easy to transform any format into another, by simply deserializing from format A and serializing to format B. But a little experiment will show you that it requires a lot of complexity for the non-trivial case. And the format's particulars will still show up in your code.

At which point it begs the question, why not just write simple primitive (de)serialization modules that only do one format? Probably easier to build, maintain and debug.

I am reminded of a binary file format I once wrote which supported referenced objects and had enough meta-data to allow garbage collection. It was a big ugly c++ template monster. Any abstract deserializer is going to stay away from that.

Reply via email to