Serialization basics

The lifetime of all objects within a program is limited by the runtime. When we stop and then reopen the program, the information about previously created objects is lost. Imagine it happens in a computer game: this behavior is not what we actually need! Fortunately, a program can save objects to some permanent storage like a hard drive and read them back the next time…

Custom serialization

We have discussed the default serialization of objects. To disable serialization of fields we used the transient keyword. But sometimes this is not enough. You may need some kind of validation fields when deserializing a project. To achieve it, you should prefer to use custom serialization. There can be some design constraints as well: the class is expected to be changed in future releases which could break the…