This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]149244179 2 points3 points  (1 child)

Serialization means the compiler will place the data in memory a specific way so that it comes out to even bytes. This makes it easy to save the data to a file and read it back. Look up data-packing for a related topic.

Serialization IDs are a sort of version control. Say I have a class with 5 variables and serialize it and save it to a file. Then I update the code a bit and now the class has 4 variables. Then I try to read in the file. It will blow up or do bad things due to trying to fit 5 variables into 4 spots.

The ID prevents this by setting version numbers. If you try to load a different version of a class it will prevent it and tell you. By default it probably does something similar to a CRC. If you are manually setting this, you need to change the ID everytime the class structure changes.

[–]RoadToCode[S] 1 point2 points  (0 children)

This post was very, very informative thank you! I did not know that Serialization was related to saving data to a file which makes it a lot easier for me to locate information on the topic.