I have 2 classes FormatA & FormatB. They hold the same data in 2 different formats for easy access for processing.
Now at some point in my application, I want to create FormatB from FormatA.
I think there should be Serializer which Serializes from FormatA to FormatB and deserializes. Now, based on the definition of Serialization, my thought process doesn't sound correct.
Serialization is the process of converting an object's state (including its references) to a sequence of bytes, as well as the process of rebuilding those bytes into a live object at some future time. Simple......Coverting an object to bytes and bytes back to object.
What is the right thing in this case to achieve the goal? I have few other possibilities:
Let class FormatA & FormatB have methods for transforming to another format.
Have utility to do the transformations with methods like transformToFormatA(formatB) and transformToFormatB(formatA).
Not sure which one is the correct way of doing this?
Aucun commentaire:
Enregistrer un commentaire