0

I'm new to serialization concept, please help in understanding concept. What exactly serialization means? I have read the definition, but could not understand in details.

How basic types (int, string) are serialized?

If we don't use serialization in our code how data will be transmitted?

Is there any implicit serialization process involved while accessing database from front end Java/C# code? example insert/delete from database.

Pang
  • 9,564
  • 146
  • 81
  • 122
Vishwas Rao
  • 121
  • 1
  • 1
  • 11
  • possible duplicate of [What is object serialization?](http://stackoverflow.com/questions/447898/what-is-object-serialization) – user207421 Sep 13 '15 at 08:06

2 Answers2

0

Serialization just takes an object and translates it into something simpler. Imagine that you had an object in C# like so:

class Employee
{
    public int age;
    public string fullname;
}

public static void Main()
{
    var john = new Employee();
    john.age = 21;
    john.fullname = "John Smith";

    var matt = new Employee();
    matt.age = 44;
    matt.fullname = "Matt Rogers";
    ...       

This is C# friendly. But if you wanted to save that information in a text file in CSV format, you would end up with something like this:

age,fullname
21,John Smith
44,Matt Rogers

When you write a CSV, you are basically serializing information into a different format - in this case a CSV file. You can serialize your object to XML, JSON, database table(s), memory or something else. Here's an example from Udemy regarding serialization.

If you don't serialize, confusion will be transmitted. Perhaps your object's ToString() will be implictly called before transmission and whatever result gets transmitted. Therefore it is vital to convert your data to something that is receiver friendly.

There's always some serialization happening. When you execute a query that populates a DataTable, for example, serialization occurred.

zedfoxus
  • 35,121
  • 5
  • 64
  • 63
0

Concept :

Serialization is the process of converting an object into series of bytes. Usually the objects we use in application will be complex and all of them can be easily represented in the form of series of bytes which can be stored in the file/database or transfered over network.

You can make a class Serializable just by making it implement Serializable interface.

For a class to be serialized successfully, two conditions must be met: The class must implement the java.io.Serializable interface. All of the fields in the class must be serializable. If a field is not serializable, it must be marked transient.

When the program is done serializing, and if it is stored in a file with extension .ser then it can be used for deserializing. Serialization gives an serialVersionUID to the serialized object which has to match for deserialization

Coder12345
  • 179
  • 3
  • 11