General programming question - circular referencing

olsonpm

Well-known member
Joined
Aug 24, 2010
Messages
46
Programming Experience
Beginner
So i've ran into this situation before, but never really worried about it. Basically I'm working on creating my own sudoku solver to learn vb.net. I decided to have an element class which represents a single square in the puzzle. That element then has references to three lists which can be validated (no duplicate numbers). The three lists then would be its corresponding row/column/subGrid. Each list then holds a reference to 9 elements. Thus in my design an element has a reference to a list, which then holds a reference to that same element. Now vb.net will allow me to do this so I don't think it is the same issue that I saw when searching for solutions to circular referencing. However, I still wonder whether or not this is bad design. Any info will be much appreciated.

thank you,
Phil
 
Having two objects referring to each other is not specifically a problem, and does happen in the Framework. For instance, a form has a Controls property that is a collection that refers to each child control. Each of those child controls has a Parent property that refers to the form. It would only be a problem if you were to implement it in such a way that navigating the hierarchy meant encountering the same object twice. In that case you would end up in an infinite loop, which is obviously bad. In the case I mentioned, if you navigate from the top down or the bottom up, you'll only ever touch each control at most once, so there's no issue.
 
Back
Top