posted 16 years ago
Some definitions and typical uses of Serialization might clear it up:
definitions:
1. state of an object - the values of the instance variables of the object... including the instance variables of any object-type instance variable of this object, and the instance variables held by ... see recursion.
2. persistent medium - disk file, database, etc.... something not "in memory".
Where an object is an "in-memory" concept, Serialization is the "not in memory" way to store an object, so it can be brought back into memory later, or by a different process.
examples:
1. Your app needs to shut down, and start up again later, with the same "state" (variables having the same value as before). You can write out the object-type variables to disk or a database by serializing them.
2. Your app needs to "talk to" another app across a network, and share data that are represented in-memory as objects that both apps understand. With serialization, you can send the objects across a socket connection with the other app. (Note that this example isn't about a "persistent medium",it's a different use of serialization)
Serialization is conceptually like this:
At this point, you don't have the exact same object (that is, xp and xp2 are at different memory addresses, possibly in different processes, possibly on a different server)... but you have an equivalent object, one with the exact same state.
Hope this helps,
-- Jon