Class design — circular references between related classes
Question: I need help trying to figure out the proper design of my classes.

I have a user class:

    
    
    class AppUser:
        _email - String
        _fullname - String
        _organizations - List of ????
        _active - Boolean
        ------------------
        getOrgs - Method
    

Also, I have an Organizations class:

    
    
    class Organization:
        _name - String
        _domain - String
        _members - List of ????
        ------------------
        getMembers
    

So, my issue is the Lists. The Org class has a list of _members. This list
should probably be a list of AppUser objects. And, the AppUser class has a
list of _organizations. This list should probably be a list of Organization
objects.

But this would create a circular reference.

So, how should I implement this?

Edit: Need to implement this using Python.


Answer: You did not specify which language you were using. That is important because
in some languages circular references do cause problems (VB6) while in others
they do not (Java, C#, etc.). In most cases you will be okay with circular
references in your class hierarchies especially if you are using a modern
language that uses garbage collection for memory management.

