Special hierarchial data structure

Kt3

New member
Joined
Jun 3, 2004
Messages
2
I'm having some serious issues writing a small app that helps me organize my thoughts.

The data structure allows for three objects.. Folders, projects, and ideas.

Folders can contain other folders, projects and ideas.
Projects can contain folders and ideas but not other projects.
Folders within projects cannot contain other projects.
Ideas don't contain anything.

The depth should be unlimited, but having programmed relational databases before I know that I should probably have a limit.

How would this be possible?
 
1. Create a Folder class, Project class and Idea class.
2. Create a FolderCollection class, ProjectCollection class and IdeaCollection class, each derived from CollectionBase.
3. Give the Folder class a Folders property of type FolderCollection, a Projects property of type ProjectCollection and an Ideas property of type IdeaCollection, each of which should be ReadOnly.
4. Do the same for the Projects class but omit the Projects property.
5. The third point is the trickiest. I think that you'd need to give the Folder and FolderCollection class another Boolean property named HasParentProject or something like that. It would be set to True in the FolderCollection class when created within a Project, probably via the constructor. Any Folder objects added to a FolderCollection would then have their property set to the same value as the collection via the Add, Insert, etc. methods. You would then have to throw an exception if a Project was added to a Folder whose HasParentProject property is True. You'd also have to throw an exception if a Folder with Projects was added to a Project. Finally, you'd have to cascade the HasParentProject value down through a Folder tree, as presumably any Folder that has an ancestor Project, no matter how far up the tree, cannot contain Projects.
 
Back
Top