Model Code: Serialization and Data Management

Let’s learn how to perform serialization and data management operations on the model.

Add a serialization function

It’s helpful to have an object serialization function tailored to the structure of an object (as defined by its class) such that the result of serializing an object is a human-readable string representation of the object showing all its relevant information items. By convention, these functions are called toString().

In the case of the Book class, we use the following code:

Get hands-on with 1200+ tech skills courses.