Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

serialVersionUID

 
Isaac Ferguson
Ranch Hand
Posts: 841
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why some classes ask me for

thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21116
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:Why some classes ask me for

thanks



Well, no classes "ask" for the variable.

However, some IDE warns you that you have a serializable class without it. The theory behind it is .. if you don't provide it, the Java compiler will generate one based on a formula. And chances are, it will be too volatile, meaning it will change the value even though you don't care about the part that changes.

So... the theory is, if the programmer controls it, then the programmer can change it only when actually needed. This way, if the programmer changes an interim variable, the programmer can choose to not change the ID, and hence, the program will still be compatible with all the previously serialized files.... and of course, this is based on the assumption that the programmer knows what he/she is doing.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic