I'd like to know what people's opinions are on the following: would you generally recommend sending data over a network using object serialization or by extracting the information from the object and then sending it as strings.
I'm concerned with portibility and not exposing too much information about the object. My thought is the less a client knows of the details the better. By serializing I'm making known the objects internals. However, serialization seems a bit more elegant as I don't need to extract information from an object, package it, send it across the network, and then unpackage on the other side as I would need to do if I sent the information as a set of strings.
If you have control over both the server and client code, using serialized objects will save a very large amount of effort.
If someone else is expected to be writing clients, or if the data going over the network represents only a small fraction of the data being processed, or if you have severe bandwidth limitations, you might want to send the data directly. In this case, it's probably better to send the data in binary form rather than as strings.
Ask yourself this question: is it worthwhile for you to write, in english, a complete specification of the protocol, saying exactly what goes in which bytes? If so, you're probably justified in taking lower level control over the connection. If not, you should just use serialized objects.
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners