[dba-VB] Serialization

John W. Colby jwcolby at colbyconsulting.com
Wed Sep 7 07:41:43 CDT 2005


Is anyone using serialization to save / restore class data to an XML stream?

I have my System Variables (SysVars), which are a pair of classes:

A SysVar class which is just a data container with a handful of public
variables.
A SysVars (plural) class which is the supervisor of The SysVar instances.
SysVars contains a collection of SysVar instances.  SysVar is supposed to
load the instances at New(), it has properties that return one specific
SysVar instance (by name) and is supposed to write any changes back out.

Using the example code I found on the MS site for using serialization, the
loading and saving of the data occurs through a Serializable data module
which takes a filename and n object type, and returns an object of that
object.  That in itself is not a huge issue, but it does mean that the class
is no longer loading its own data, i.e. you must now dim a variable and then
call the SerializableData class, which returns an instance of SysVars with
the data loaded.  

My question is, can a class have methods that serialize and deserialize its
own data, making it self contained, or is it just necessary to do this from
outside the class?

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/





More information about the dba-VB mailing list