|
-
Jan 5th, 2002, 07:31 PM
#1
Circular Reference Problem
I have a file (it's an xml file but that doesn't matter) that contains records with several fields. The two important fields are "name" and "extends". "name" is the name of the record and "extends" is the name of another record in the file. This structure allows chains of records to be created (like a linked list). Here is an example:
(record 1) name: A extends: B
(record 2) name: B extends: C
(record 3) name: C extends: D
(record 4) name: D extends: (blank)
In my program the user can change or add "extends" values and I want to prevent circular references. For example a new extends value of "E" for record 4 would be Ok, but "A", "B", "C" or "D" would not be. I have a routine that finds the circular reference error if "B", "C" or "D" are entered, but it doesn't work for "A". Any ideas?
-
Jan 6th, 2002, 02:00 PM
#2
-
Jan 6th, 2002, 03:17 PM
#3
Hyperactive Member
You could use arbitrary internal names determined by the code during the adding process by checking a value in the file for the next name to use, using that name, and updating the file with the next name to use for the next time something is added? Not sure entirely what you want.
-
Jan 6th, 2002, 06:44 PM
#4
Let me try to explain what I need in a different way. The file is a list of class objects that will drive a business process. Each class has properties and one class can inherit the properties of another class (or in other words extend it). The users of this tool create the classes and specify their properties and decide if one class extends another. I want to prevent them from accidently creating an inheritence chain that is circular. A circular chain in my example below would occur if D was set up so that it was indicated that it extended A, B or C.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|