• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

serialization

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do we serialize an object?I know we can send data without using the concept of serialization?then why to serialize objects?
Please answer
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I know we can send data without using the concept of serialization


We can send data, but we can't transfer an object without Serialization.
[ February 16, 2006: Message edited by: Paul Sturrock ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to nitpick about what Paul said - it depends on your definition of "object equality" and "serialization".

If you're talking about the actual object instance (which is identical in the sense of "=="), then Paul is exactly right: you need to use Java object serialization, and only a Java client will be able to make sense out of it.

If you're talking about an object that is identical in the sense of the "equals" method, you can use other serialization methods (e.g. java.beans.XMLEncoder or the serialization used in Web Services) to get an object which acts the same way the original would have.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
I'm going to nitpick about what Paul said - it depends on your definition of "object equality" and "serialization".

If you're talking about the actual object instance (which is identical in the sense of "=="), then Paul is exactly right: you need to use Java object serialization, and only a Java client will be able to make sense out of it.

If you're talking about an object that is identical in the sense of the "equals" method, you can use other serialization methods (e.g. java.beans.XMLEncoder or the serialization used in Web Services) to get an object which acts the same way the original would have.



I can't make any sense of this reasoning, but I strongly suspect that it is inaccurate. You can certainly use any kind of serialization to serialize and deserialize to the same instance - even standard Java serialization, which is extremely inflexible. Likewise, you can do the same for any object such that the equals method (ick) evaluates to true.

http://contractualj.com/api/net/tmorris/serialization/SerializationScheme.html can also do permit all of that and more.
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Serialization is a mechanism where a Java object can be preserved across a network. Essentially, it is an object encoded in a specific format such that it can be 'recreated' on a different machine with the same data.

Originally posted by Ulf Dittmer:

If you're talking about the actual object instance (which is identical in the sense of "=="), then Paul is exactly right: you need to use Java object serialization, and only a Java client will be able to make sense out of it.



Not true. By definition, an object is 'recreated'. This means that the new object will have a totally different memory address even if it is deserialized in the same VM. Thus, the '==' operator will always return false when comparing an object and its serialized/deserialized version and the 'equals' method will always return true.
 
reply
    Bookmark Topic Watch Topic
  • New Topic