Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures Organizing Data Serialization

Greg Austin
Greg Austin
10,890 Points

serialVersionUID

So I noticed we could've also taken the serialVersionUID from the caught exception. Just wanted to make sure I'm getting this right: "stream classdesc serialVersionUID" is the saved object's UID; "local class serialVersionUID" is the class's current UID, at time of compilation--and does that mean that one boolean was responsible for such apparently-dramatic (perhaps there's a pattern I'm not seeing...I am under the impression that computers like to store info in random binary addresses, anyway...) change in the UID?

Is there more to it than this? Is there a way to save multiple versions of an object using serialization, or must they be overridden?

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Greg!

Yeah you are right, it does seem drastic, but each little change generates a different UID for serialization purposes. The attempt is to ensure that you know the class is different.

Serialization is very fragile, and yes you could use the error message as well. Best practice says you create that field (using serialver) when the dust has settled in your class modelling and you are ready to begin serialization. And most likely most serialization will be done with a database or document store, we just quite aren't there yet.

Thanks for bringing it up!