Re: Pattern for plugins, archiving, and dynamic document data model?
Re: Pattern for plugins, archiving, and dynamic document data model?
- Subject: Re: Pattern for plugins, archiving, and dynamic document data model?
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 30 Aug 2001 11:37:57 -0500
Our approach to your problem follows:
We store all document data as ASCII text. XML or old style property lists
are fine.
When we read document data, we read plain strings and store them.
We build the model object graph by giving each model object including
available plugins a chance to instantiated themselves based on the ASCII
data. Any ASCII data that is not claimed by any model object is preserved
unmodified as ASCII data. When we save the model, each object in the
model's graph of objects contributes ASCII text. The collection of ASCII
text from all of the model objects and from the unclaimed ASCII text is
written.
All of this is made easier because we have code to archive arbitrary objects
graphs as ASCII property lists and read them back. Multiple references to
the same object are preserved. Cycles are not a problem. Conditional
archiving is supported. It works just like NSCoder except that the encode
methods are different and it stores ASCII rather than binary.