How to Achieve Persistence? II

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]

*If neither the programming language, nor its standard library, nor the operating system supports persistence, it is still possible to implement a library for this. This is more easily achieved in object-oriented languages but also traditional languages attempted it. The first idea for this was published by Herlihy (1982), an object-oriented implementation was provided by Borchert for Oberon (1994).
*The principal idea is that each persistent class provides so-called marshaling procedures that convert an object into a sequence of bytes (on some stream) and that are able to construct an object on base of such a sequence of bytes.
*Problem: Writing such objects is easy but how to locate a reading method? Or better: How to construct the right object that has to be asked to read itself?
*Solution: The design pattern of object factories helps. Maintain a registry with class names and associated constructor objects. Each object that is written to an output stream must be preceded by a class information (usually just a string that specifies the name of the class). On reading, first the class name is read, then the factory is asked to find the constructor object associated with that class name. Afterwards the constructor object creates an instance of that class using the marshaling constructor which takes an input stream as argument.
*Drawback: All persistent objects must belong to classes that are derived from a abstract base class for persistent objects.
*Another drawback for C++: No free matured solution for C++ is known to me. Only commercial or experimental libraries.

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 21, 2002