I am trying to understand the concept of serialization. In many articles, serialization is the process of converting an object to the sequence of bytes ( binary data) and it is very useful while transmitting object over the network.
I got some confusion here. Let us say, I have an object of class which I would like to pass it to a remote procedure. When I say object means, itself represents a set of bits and bytes in the same computer ( since computer holds any data in the form of bits and bytes). Here, it is transferring that bits and bytes over the network. right ? I do not the understand serialization concept here.
Any help is appreciated. Thanks.
An object of a class will contain pointers, references or whatever, to strings and other sub-objects. These pointers are memory addresses that are meaningful only in the sending computer’s address space, and so will not be valid if they are sent over the network to another computer.
In other words, if you send an object’s bytes as it exists in memory over the wire, you will only get its shell at the other end, and all of its contents will be lost. The object will instead just contain pointers to meaningless memory locations.
The process of serialization involves following those pointers and serializing the objects on the end of them, so that the whole object graph can be sent over the wire and then reassembled at the other end, fixing the pointers so that they are correct for the destination computer’s address space.