Many-to-many relationship in oop
- by Manu
what is best way to model many-to-many relationship?
lets say we have a two classes , Team and Player
any given Player can be in multiple Team s
any Team can have as many Player s as they like
I like to call methods like
playerX.getTeamList() to get the list of all the Team s he/she is in
teamY.getPlayerList() to get the list of all the Player s in the team
(or have some other way to do this effectively)
I can think of two ways of doing this , but they just don't feels like good oop pattens.
can you think of any good ways , perhaps a design patten ?