What does this text mean

T

Tony Johansson

Hello!

Here is some text from a book that I'm reading.
"Typically, when you serialize an object, the destination does not matter.
In some circumstances, however, you might want to serialize and deserialize
an object differently depending on the destination. For example, you should
typically not serialize members that contain information about the current
process, because that information might be invalid when the object is
deserialized. However, that information would be useful if the object is
going to be deserialized by the same process. Alternatively, if the object
is useful only if deserialized by the same process, you might choose to
throw an exception if you knew the destination was a different process."

First the text says this which sounds correct and understandable (*For
example, you should typically not serialize members that contain information
about the current process, because that information might be invalid when
the object is deserialized.*)

Then some rows below the text says something that I don't understand
(*However, that information would be useful if the object is going to be
deserialized by the same process.*)

//Tony
 
J

Jeff Johnson

Here is some text from a book that I'm reading.
"Typically, when you serialize an object, the destination does not matter.
In some circumstances, however, you might want to serialize and
deserialize an object differently depending on the destination. For
example, you should typically not serialize members that contain
information about the current process, because that information might be
invalid when the object is deserialized. However, that information would
be useful if the object is going to be deserialized by the same process.
Alternatively, if the object is useful only if deserialized by the same
process, you might choose to throw an exception if you knew the
destination was a different process."

First the text says this which sounds correct and understandable (*For
example, you should typically not serialize members that contain
information about the current process, because that information might be
invalid when the object is deserialized.*)

Then some rows below the text says something that I don't understand
(*However, that information would be useful if the object is going to be
deserialized by the same process.*)

The theory makes sense to me, but I'm having difficulty in coming up with a
real-world example to help you understand it. All I can think of is that
perhaps you have some sort of memory-intensive process and you need "swap
space." You need to serialize some of your items to disk--but you might need
them later and they might contain process-specific information. If you know
that you will be deserializing those items from the same process that
serialized them in the first place, then storing that process-specific
information would be a good idea.

Let me put it another way: 99.999% of the time you probably won't want to
serialize process-specific information, but it's possible you'll want to.
 
A

Arne Vajhøj

Here is some text from a book that I'm reading.
"Typically, when you serialize an object, the destination does not matter.
In some circumstances, however, you might want to serialize and deserialize
an object differently depending on the destination. For example, you should
typically not serialize members that contain information about the current
process, because that information might be invalid when the object is
deserialized. However, that information would be useful if the object is
going to be deserialized by the same process. Alternatively, if the object
is useful only if deserialized by the same process, you might choose to
throw an exception if you knew the destination was a different process."

First the text says this which sounds correct and understandable (*For
example, you should typically not serialize members that contain information
about the current process, because that information might be invalid when
the object is deserialized.*)

Then some rows below the text says something that I don't understand
(*However, that information would be useful if the object is going to be
deserialized by the same process.*)

It is plain English.

In some cases you may store process specific information
if you know that the information will always be read by the
same process.

I don't think that is a scenario that happens frequently, so
if I were you then I would not waste time diving into that.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top