lundi 23 mars 2015

Is is a bad design to have a structure where one class contains list of another class and vice versa

I was working on design of User Role Management system. In this system a user can have many roles and a role can have many users. It is one to many relationship in between both user and role. I was thinking of a design to establish this relationship as:



Class User
{

List<Role>
}

Class Role
{
List<User>
}


My question is, Is this a bad design.If yes what should be the recommended way to establish relationship.


Regards


Aucun commentaire:

Enregistrer un commentaire