[dba-VB] Inheriting collections

John W. Colby jwcolby at colbyconsulting.com
Mon Jul 25 18:17:45 CDT 2005

Being new to this inheritance thing (in the last 15 years), I have a
conceptual question:

In my SysVarRec I use a data class (or structure) that holds one record's
worth of SysVar data from a specific table.
I use a SysVarsTbl class that holds a collection of SysVarRec instances.
This class loads all of the sysvar records from a single table, loading each
record's data into a SysVarRec class or structure.
I use a SysVars class which loads one or more instances of SysVarsTbl,
storing each SysVarsTbl class into a collection.  ADDITIONALLY, this class
then merges all of the SysVarsTbl class' data into a single collection of
SysVars.  This collection is nothing more than a keyed collection, where the
value is stored, with a key to index into the collection.  The objective
here is to allow several different copies of a SysVars table to exist, where
the "last loaded wins".

For example, suppose I have a SysVar called EnableZip, whose value is
True/False.  If True the Zip functionality is loaded as the framework sets
up.  In the framework's copy of tblSysVars, EnableZip exists but is set to
false.  Thus as the framework initializes, the zip functionality is not
loaded.  In the application's copy of tblSysVars, EnableZip is True because
this application needs to zip files.  The tables load Framework.tblSysVar
and then Application.tblSysVars.  EnableZip=false loads from the framework
table, but then the EnableZip=True loads from the application table loads
and "overrides" the framework's SysVar.  What really happens is that the
EnableZip is found already loaded and changed from False to True.  Thus by
the time the application table finishes loading, EnableZip is True and the
zip functionality of the framework loads.

Well, you get the idea anyway.  Think up your own scenario.

The question now is...

Since a class can be inherited, should SysVarsTbl inherit the collection
class so that all of the collection functionality is native to the
SysVarsTbl class?  Or should the SysVarsTbl class simply have a collection
class variable that it sets up and loads an instance of the collection
class?  IOW, SysVarsTbl needs a collection but it could BE a collection or
it could just dim and use a collection.

VBA did not have this ability, so I became accustomed to just "consuming"
collections, i.e. using them.  But now the class that needs a collection
could BE a collection class, with all of the functionality of the collection
class inherited right in and specific non-collection functionality added to
it (loading records out of a table for example).

John W. Colby

Contribute your unused CPU cycles to a good cause:

More information about the dba-VB mailing list