Many-to-many relationship in oop
Posted
by Manu
on Stack Overflow
See other posts from Stack Overflow
or by Manu
Published on 2010-05-06T12:20:47Z
Indexed on
2010/05/06
12:28 UTC
Read the original article
Hit count: 160
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 inteamY.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 ?
© Stack Overflow or respective owner