Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Posts syndicated from ParasDoshi.com.
Browse by Tags · View All
beyondrelational.com 87
Cloud computing 34
Microsoft 32
sql 32
SQL 32
sql azure 32
#sqlazure 28
Database 24
Microsoft SQL Server 24
#azure 12

Archive · View All
April 2012 12
June 2012 11
February 2012 11
July 2012 10
August 2012 8
May 2012 8
March 2012 8
January 2012 6
October 2012 3
November 2011 3

ParasDoshi.com

What is Serialization? May be Star Trek analogy could help..

Feb 11 2012 12:00AM by Paras Doshi   

I recently played with XML serialization:

1

In super simple terms, (one of the) aim of serialization is to convert an object (not a class) that can be transported.

There are two processes that are attached to Serialization viz. deserializing and serializing AND to understand that – let’s draw an analogy with star trek:

Remember Transporter?

image

Source: http://en.wikipedia.org/wiki/Transporter_%28Star_Trek%29

Transporters convert a person or object or matter into an energy pattern –> then “beam” it to a target –> where it is reconverted into matter

In programmer’s world:

Serialization equals “convert a person or object or matter into an energy pattern”

Deserialization equals “where it is reconverted into matter”

Technical (accurate) Definition from Wikipedia:

In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and “resurrected” later in the same or another computer environment

 Let’s Simplify that!

we need to serialize the object when 1) an object is to be sent over the network 2) state of an object is to be saved.

Moral of the story

To send an object via network, it is serialized.

After it’s received, to recover it, it is deserialized.

Now let’s get into action!

I am familiar with .Net framework– so I am going to share a demo code for XML serialization (serializing + deserializing) with you.

Here’s the class definition (person.cs). Just a simple object for demo purpose:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace XMLSerialization

{

class person

{

static void Main(string[] args)

{

}

public class person

{

private string _firstname, _lastname, _twitter;

public person()

{

_firstname = "";

_lastname = "";

_twitter = "";

}

public string firstname

{

get { return _firstname; }

set { _firstname = value; }

}

public string lastname

{

get { return _lastname; }

set { _lastname = value; }

}

public string twitter

{

get { return _twitter; }

set { _twitter = value; }

}

}

}

}

Code for Serializing an object:


class Program

{

static void Main(string[] args)

{

person personone = new person();

personone.firstname = "paras";

personone.lastname = "doshi";

personone.twitter = "@paras_doshi";

Console.WriteLine("serializing....");

XmlSerializer serializer = new XmlSerializer(typeof(person));

string path = ".\\filename.xml";

FileStream fs = File.OpenWrite(path);

XmlTextWriter writer = new XmlTextWriter(fs,System.Text.Encoding.UTF8);

writer.Formatting = Formatting.Indented;

try

{

serializer.Serialize(writer, personone);

}

finally

{

writer.Close();

}

Console.WriteLine("Serialization: Done!");

}

}

Code to deserialize an object:


Console.WriteLine("Deserialization.....");

XmlSerializer serializer = new XmlSerializer(typeof(person));

string path = ".\\filename.xml";

FileStream fs = File.OpenRead(path);

person deserializeperson;

try

{

deserializeperson = (person)serializer.Deserialize(fs);

}

finally

{

fs.Close();

}

Console.WriteLine("Person info:");

Console.WriteLine("First Name: {0}", deserializeperson.firstname);

Console.WriteLine("Last Name: {0}", deserializeperson.lastname);

Console.WriteLine("Twitter: {0}", deserializeperson.twitter);

reference: http://msdn.microsoft.com/en-us/library/182eeyhh%28v=vs.71%29.aspx

BTW,
I hope that STAR TREK analogy was helpful!



Republished from Paras Doshi's Blog [61 clicks].  Read the original version here [1 clicks].

Paras Doshi
17 · 10% · 3265
4
 
0
Lifesaver
 
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • Start Trek did help! Now, where's my collection of DVDs???? :)

    commented on Feb 11 2012 2:07AM
    Nakul Vachhrajani
    4 · 36% · 11624
  • I am glad that was helpful! I hope you find your DVD's - have fun - watch star trek!

    commented on Feb 11 2012 2:27AM
    Paras Doshi
    17 · 10% · 3265

Your Comment


Sign Up or Login to post a comment.

"What is Serialization? May be Star Trek analogy could help.." rated 5 out of 5 by 4 readers
What is Serialization? May be Star Trek analogy could help.. , 5.0 out of 5 based on 4 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]