Home > Java > Serialization – The why part

Serialization – The why part

Recently I was interacting with some of my folks and find that mostly they have used serialization but have not realized much. And I thought, I can also learn different views from my blog readers (Trust me there are some ;) ) by posting my views. So my definition, here you go.

As all of you know, Class is nothing but a complex data type represents real world objects with the help of primitive data types. Grouping primitive data and bringing meaningful definition. When you transferring an object from machine to A to B, litteraly the object will be recreated (Nobody can make magic here. The newly created object would be created in a new memory location and will be initialized with the same state (the values) what the object was holding in machine A.

What is serialization?
“Streaming your class state over wire”

Why do you need serialization?
Say you want to transfer an object (naturally with some state otherwise will you call as object? thats class right?) to machine A to machine B, how do you that? Serialization converts the state to binary.

What is Marshalling and Un-marshalling?
If you look into deeper the serialization, its Marshalling and Un-marshalling. Marshalling – The process converts state to binary and Un-marshalling does the vice versa.

Java provides default implementation, geeks can have their own algorithm to customize this process.

Sometimes if you dont need to transfer the state of a particular data member then you can declare that variable as transient variable and make Java life simpler. When object is being created at other end the transient data member will be initialized by default value.

In my next post, lets see my views on the PMD rule BeanMembersShouldSerialize and the decision I have taken.

Folks, feel free to redefine, extend or agree :) my views on serialization.

About these ads
Categories: Java
  1. December 28, 2010 at 4:06 am | #1

    good info, you have a great blog here! I’m definitely going to bookmark! I have a Technology (in category) blog. It pretty much covers related stuff.

    Come and check it out if you get time :-)

    • krkaleraj
      December 28, 2010 at 6:27 am | #2

      Thanks Fahru. Keep reading

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: