Results 1 to 4 of 4

Thread: Circular Reference Problem

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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?

  2. #2

  3. #3
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    I'm in front of the computer.
    Posts
    270
    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.
    Alphanos

  4. #4

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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
  •  



Click Here to Expand Forum to Full Width