Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization

 
Albin Joseph
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the disadvantages of Serializable interface. Is there any performance or any kind of issues associated with Serializable interface.
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sliding over to the intermediate forum...
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is really no performance hit if you implement Serializable, but you should implement it with care. Not everything should be Serializable. Remember if you make something Serializable, then its entire object tree must also be Serializable. So it could turn into a lot of extra work for no good reason.

Also, you probably don't want to make everything Serializable because some objects should not be serialized. For examples, GUI objects (in general) should not need not need to be serialized. If they do, that may be an indication of bad design.

Bottom line is, just because you can implement Serializable for everything doesn't necessarily mean you should.
 
Avinash Ramana
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/developer/technicalArticles/Programming/serialization/

Excellent article.

I've actually been working a lot with serialization in conjunction with Quartz Scheduler. I'm basically putting a serialized class(x.y.Clazz) into the database (blob) and then when it gets pulled to execute the x.y.Clazz , the version has changed because I updated it while x.y.Clazz was persisted.

I solved it by other means. But I realized the solution would be to start using XML because it's easier to manage certain aspects like not knowing where our classes were going..

Check this out for future gotchas

http://www.javaworld.com/javaworld/jw-02-2006/jw-0227-control.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic