Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a serializable object?

What is a serializable object in C#? I guess the word serializable is throwing me off more than "serializable object".

like image 379
Frank Avatar asked Aug 20 '09 04:08

Frank


People also ask

What does it mean if an object is serializable?

Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.

What is a serializable object in JS?

The process whereby an object or data structure is translated into a format suitable for transfer over a network, or storage (e.g. in an array buffer or file format). In JavaScript, for example, you can serialize an object to a JSON string by calling the function JSON.

What is serialization with example?

In computing, serialization (US and Oxford spelling) or serialisation (UK spelling) is the process of translating a data structure or object state into a format that can be stored (for example, in a file or memory data buffer) or transmitted (for example, over a computer network) and reconstructed later (possibly in a ...

What is the purpose of object Serialisation?

Serialisation is used in the cases where you want to save an object state and convert that object into byte stream, objects need to be serilazed. While you're running your application, all of its objects are stored in memory (heap memory).


1 Answers

Normally objects are random access, that is, you can specify any part of an object (property or field) and access that part directly. That's all well and fine if you're using RAM to store an object, because RAM is Random Acess Memory and is therefore suited to the job.

When you need to store your object on a medium that is not traditionally random access, for instance disk, or you need to transfer an object over a stream medium (such as the network) then the object needs to be converted into a form that is suitable to the relevant medium. This conversion process is called serialization, because the structured object is flattened or serialized, making it more amenable to being stored for the long term, or transferred over the network.

Why not just copy the bits comprising the object in RAM to disk, or send it as an opaque blob over the network? ... you may ask. A few issues:

  1. Often the format that the object is stored in memory is proprietary and therefore not suitable for public consumption--the way in which it is stored in memory is optimised for in-memory use.
  2. When an object references other objects, those references only have meaning within the context of the running application. It would not be possible to deserialize the object meaningfully unless during the serialization process, the object graph was walked and serialized accordingly. There may be a need to translate those references into a form that has meaning outside the context of an application instance.
  3. There may be an interoperability requirement between heterogeneous systems, in which case a standard means of representing the object is required (typically some form of XML is chosen for this).
like image 131
Eric Smith Avatar answered Oct 01 '22 22:10

Eric Smith