Marshalling and casting. Are they related?

Last week, a young student asks me if marshalling is the same as casting. My answer was definitely not. Marshalling is a seralization, a way of converting an object's memory representation into bytes for transmission to the network, whereas casting involves type conversion / coercion.

Later, after rethinking the question, I thought that sorting could be viewed as a special case of casting. For example, converting a memory representation to xml, then you can say that you "cast" on the type defined by the corresponding xsd grammar of this xml file.

What do you think about this?

+1


a source to share


3 answers


Casting does not change the data type. This is an important distinction. When you marshal something, you convert the data to something else.

A simple introduction only changes how you interpret the object, not the object that is inside.



I agree that the distinction should be clear and other strangers may be confused.

+3


a source


Marshalling is usually associated with the technology frontier (for example, through the network or from one type of memory to another, as in the case of managed / unmanaged), whereas casting tends to be on the same technology frontier, so I think they are definitely different.



It would be completely incomprehensible if we used the same term for both approaches, that is, we would need to define them differently, since they have different types of behavior.

0


a source


They are both "type conversions", but they represent different types of type conversions: casting usually occurs between related object types (eg, demotion from superclass to subclass), while sorting can be, for example, from object graph to text representation.

-1


a source







All Articles