Packaged Persistence

Note: This is a rough hack, nothing more.

Problem

How do you implement a persistance mechanism which is sufficiently robust and sufficiently generic?

Context

An object oriented application that requires the ability to persist object data.

Forces

1. More than one distinctly different media/container is being persisted into and these media/containers use at least two different storage paradigms (i.e. serial, random access, database).

and/or

2. The lifespan of the data files is expected to be significant in comparison to the rate of change in the software. In other words, the designers expect to see cases where newer versions of the software are reading older data files.

Solution

Each persistence medium/container implements a "package" class. The package class is an Adaptor with a known interface that allows each component object to store data of any primitive data type supported by the implementation language (and optionally, certain non-primitive extensions such as strings) plus objects or object references.

On the transmit/write side, the component object which is to be persisted is passed a "write package" object, to which it writes whatever data it requires. The package object bundles the data up in whatever fashion is required by the persistence medium/container (including but not limited to things such as ASCII/binary format, endianism etc) and passes it on.

On the receive/read side, a "read package" object is created and given its data by the persistence media/container. A blank component object is created and passed the package object. The blank component object uses the the package to read and/or resolve its data attributes and object references. This process may include resolving differences in the current and stored versions of the class.


CategoryPersistence


EditText of this page (last edited August 9, 2005) or FindPage with title or text search