Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Object serialization vs String data for network communication

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

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.

Your thoughts are appreciated. Thanks.
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic