Why do we need Serialization?

When you create an object in a .NET or Java application, you don’t need to think about how it is stored in memory, because the .NET/Java framework takes care of that for you and does the necessary serialization.

What about when you need to:

> store the object to a file OR

 > send an object to another process OR

 > transmit an object over the network

You do have to think about how the object is represented because you will need to convert it to a format that will compatible with the above requirements. This conversion to a compatible and suitable format is called Serialization.

The basic mechanism is to flatten an object into a one-dimensional stream of bits, called Serialization, and to turn that stream of bits back into the original object, called De-Serialization.

In other words, Serialization is persisting an object from memory to a sequence of bits, for instance for saving onto the disk or handing it to some other process. De-serialization is the opposite – reading bits from the disk or network to create an object in its original form.

In other words, Serialization equates to saving the current state of an object to a stream, and restoring to the original object from that stream is De-Serialization.

Another definition can be:

Serialization is the process of converting an object or objects into a contiguous stream of bytes. De-serialization is the process of converting a continuous stream of bytes back into objects.