Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Size of serialized classes

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using serialized ValueObject classes as return values from some stateless session EJBs. In other words, I'm sending classes that are basically just data containers across the network, and to go from JVM to JVM, they have to be serialized. Obviously, I want to keep these classes as small as possible, so that not too much data is being transmitted, thus potentially hampering performance.

So my question is whether anyone know if adding methods to these classes actually increases their serialized sizes. Assume that the methods I am considering adding do not necessitate any more members variables. An example might be that one of my classes has a few different variables that might represent its "name". If I add a complex getDisplayName() method that uses a bunch of logic to figure out for a given context what its "name" is, will I have increased the size of that class' serialized form?

Thanks in advance!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dave taubler:
So my question is whether anyone know if adding methods to these classes actually increases their serialized sizes.

Dave,

Adding methods does not affect the serialized size. It does affect the size of the compiled .class file, but that's separate.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you may write a serialized class to disk, modify it, save it again, and then compare yourself.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It helps to understand this stuff if you get picky about nomenclature.
You do NOT "write a serialized class to disk" you serialize an instance of a class. The size of this file will depend on the serialized instance variables and has nothing to do with the methods.

All of the class methods live in the .class file as created by the compiler.

Bill (being picky )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic