C
Craig Buchanan
I have three classes in my application, ObjectBase, Folder and Document.
Folder inherits ObjectBase as does Document. I store common information in
a table named 'Object' and additional information in tables named 'Folder'
and 'Document' respectively. In the Object table, I have a field TypeId
that indicates where the object is a Folder or a Document.
Currently, when I create an instance of Folder or Document, I run the
appropriate stored procedure, load the ObjectBase's properties, then the
properties of the inherited class.
In the ObjectBase table, I have a Parent property that returns an Object.
An object's parent can be a Folder or a Document. Currently, I am using a
case statement in the ObjectBase.Parent property to create an instance of a
Folder or Document based on the value of the parent's TypeId.
This seems a bit awkward. Is there a better approach? As I may add more
inherited object types, I would need flexibility.
Thoughts appreciated,
Craig
Folder inherits ObjectBase as does Document. I store common information in
a table named 'Object' and additional information in tables named 'Folder'
and 'Document' respectively. In the Object table, I have a field TypeId
that indicates where the object is a Folder or a Document.
Currently, when I create an instance of Folder or Document, I run the
appropriate stored procedure, load the ObjectBase's properties, then the
properties of the inherited class.
In the ObjectBase table, I have a Parent property that returns an Object.
An object's parent can be a Folder or a Document. Currently, I am using a
case statement in the ObjectBase.Parent property to create an instance of a
Folder or Document based on the value of the parent's TypeId.
This seems a bit awkward. Is there a better approach? As I may add more
inherited object types, I would need flexibility.
Thoughts appreciated,
Craig