Implementation of serialization

Presentation

Document concerned

This document deals with the serialization/de-serialisation of a persistent object. I am writing this short document to clarify the necessary programming work.

Versions

06/12/2016: initial version

Author

Invisible Media

Project

Framework of the project

This project is a digital and algebraic calculation software. This project is a way to train very long and tedious equations and to factor them according to a common approach. Goal: solve equations, find all the solutions algebraically and get an equation based on parameters and fixed digital data.

All the features

The set of features is detailed in this document: All features (unbundled) .xlsx

Name of the feature covered here

Reading/backup by serialization

Relative need

Binary serialization is the best solution. Unlike with XML serialization, the only necessary to a binary serialization attribute is to add the Serializable attribute before the class declaration. Lists several items are entirely managed with no additional adaptation; which is not the case in lists with XML Serialization. The data can be dynamic; no strong typing is required; the backup is made from the inner content of the object and the serialization occurs recursively on each field.

Relationship with other features

Use

The data is recorded, read and changed over time via the data model


!!!Explanations
This is to deal with all the versions of the data model. However, a binary serialization means that all data are registered in the persistent file. Once this file has been saved on disk, to resume, just dé-sérialiser. Except that if the software is to a later version, all the non-existent data in the file triggers a null that it is difficult to take into account data fault. In this case, the software should revert to a previous version. When the system uses the earlier version, he also supervises all later versions.

Programming


The serialization function is carried out with the .NET BinaryFormatter class; it instantiates the serialization and de-serialisation functions.

Serialization is formed by reading all of the objects contained in the item to persist. This persistent object is simply a list of name/value pairs whose value should be of the type associated with the definition of the name in the static class definition of the name/type pairs. This check is performed at each change of the value of the element associated with the name.

The de-serialisation requires the type of data initially contained in the file. The static class of couples name/type is not present in the file; It is just built upon the launch of the application.

Once the de-serialisation has been performed, the data has been loaded. If an error occurs (which should never happen) then it will have failed to load.
Note that each file has a version number of the software; If a file is not the correct version, this problem is fixed once the file overwritten and saved with the new version.


Last edited Dec 11, 2016 at 9:38 PM by skercrow, version 1